Skip to content

Commit

Permalink
fix(schematics): print additional error info with --verbose flag in…
Browse files Browse the repository at this point in the history
… affected command
  • Loading branch information
dherges authored and vsavkin committed May 2, 2019
1 parent 0ef6c35 commit 5318f00
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/api-npmscripts/affected.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Uncommitted changes

Untracked changes

### verbose

Print additional error stack trace on failure

### version

Show version number
14 changes: 10 additions & 4 deletions packages/workspace/src/command-line/affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface AffectedOptions extends GlobalNxArgs {
onlyFailed?: boolean;
'only-failed'?: boolean;
'max-parallel'?: boolean;
verbose?: boolean;
}

// Commands that can do `ng [command]`
Expand Down Expand Up @@ -110,7 +111,7 @@ export function affected(parsedArgs: YargsAffectedOptions): void {
break;
}
} catch (e) {
printError(e);
printError(e, parsedArgs.verbose);
process.exit(1);
}
}
Expand All @@ -132,8 +133,12 @@ function getProjects(
);
}

function printError(e: any) {
console.error(e.message);
function printError(e: any, verbose?: boolean) {
if (verbose && e.stack) {
console.error(e.stack);
} else {
console.error(e.message);
}
}

async function runCommand(
Expand Down Expand Up @@ -333,7 +338,8 @@ const dummyOptions: AffectedOptions = {
base: 'base',
head: 'head',
exclude: ['exclude'],
files: ['']
files: [''],
verbose: false
};

const nxSpecificFlags = Object.keys(dummyOptions);
3 changes: 3 additions & 0 deletions packages/workspace/src/command-line/nx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ function withAffectedOptions(yargs: yargs.Argv): yargs.Argv {
type: 'boolean',
default: false
})
.option('verbose', {
describe: 'Print additional error stack trace on failure'
})
.conflicts({
files: ['uncommitted', 'untracked', 'base', 'head', 'all'],
untracked: ['uncommitted', 'files', 'base', 'head', 'all'],
Expand Down

0 comments on commit 5318f00

Please sign in to comment.