Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jpb committed May 18, 2019
1 parent d18a213 commit 2387a57
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 29 deletions.
8 changes: 0 additions & 8 deletions @types/yargs-unparser/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// // declare module 'yargs-unparser' = function unparse(o: object): string[];
// declare module 'yargs-unparser' {
// function unparse(o: object): string[];
// // export typeof unparse;
// export = unparse;
// // export default () V ;k
// }

declare module 'yargs-unparser' {
function unparse(o: object, c: { command?: string, alias?: object, default?: object }): string[];
export = unparse
Expand Down
7 changes: 2 additions & 5 deletions src/cfn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,9 @@ export async function updateExistingMain(argv: GenericCLIArguments): Promise<num
return SUCCESS;
} else {
for(const stack of stacks) {
const args = [process.argv[1], 'update-stack', stack.argsfile, ...unparseArgv(stack.argv, stack.argsfile)];
const args = [process.argv[1], 'update-stack', stack.argsfile, ...unparseArgv(stack.argv)];

const envVars: string [] = []
for (const name in stack.env) {
envVars.push(`${name}=${stack.env[name]}`);
}
const envVars = _.reduce(stack.env, (acc: string[], value, name) => acc.concat(`${name}=${value}`), []);
logger.info(`${envVars.join(' ')} ${args.join(' ')}`);

const env = { ...process.env, ...stack.env };
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function buildArgs(commands = new LazyCommands(), wrapMainHandler = wrapC
'update-existing',
description('update existing tracked stacks'),
(args) => args
// .demandCommand(0, 0)
.demandCommand(0, 0)
.usage('Usage: iidy update-existing'),
wrapMainHandler(commands.updateExistingMain))

Expand Down
16 changes: 3 additions & 13 deletions src/tracking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as path from 'path';
import * as yargs from 'yargs';
import {Arguments} from 'yargs';
import unparse = require('yargs-unparser');
import {buildArgs} from '../main';

import * as yaml from '../yaml';

Expand All @@ -26,8 +25,8 @@ function importedEnvVars(argsfile: string): string[] {
const vars: string[] = [];
const argsdata = yaml.loadString(fs.readFileSync(argsfile), argsfile);
if ('$imports' in argsdata) {
for(const key in argsdata['$imports']) {
const value = argsdata['$imports'][key];
for(const key in argsdata.$imports) {
const value = argsdata.$imports[key];
if (typeof value === 'string' && value.match(/^env:/)) {
const name = value.split(':')[1];
if (typeof name === 'string' && name.length > 0) {
Expand Down Expand Up @@ -61,23 +60,14 @@ function usedEnvVars(argsfile: string): Record<string, string> {
return envVars;
}

export function unparseArgv(argv: Partial<Arguments>, argfile?: string) {
export function unparseArgv(argv: Partial<Arguments>) {
// @ts-ignore
const options = yargs.getOptions();
const args = unparse(argv, {
alias: options.alias,
default: options.default
});
return args;
// const ignoredArgs = [
// 'update-existing',
// 'create-stack',
// 'update-stack',
// '--track',
// '--argsfile',
// argfile
// ];
// return _.filter(args, (arg) => !_.includes(ignoredArgs, arg));
}

function stackMetadata(stackName: string, argsfile: string, argv: Arguments): StackMetadata {
Expand Down
2 changes: 0 additions & 2 deletions stack-args.test.yaml

This file was deleted.

0 comments on commit 2387a57

Please sign in to comment.