Skip to content

Commit

Permalink
feat: Resolve paths to nyc & nodeunit (#887)
Browse files Browse the repository at this point in the history
Resolves paths to `nyc` and `nodeunit` from node-provided dependencies,
so that it is possible to use `npm run test` from packages without having those
installed globally or having the `lerna`-modified `$PATH`.

Also allows configuring different executables from CLI arguments or environment
variables.
  • Loading branch information
RomainMuller authored Oct 10, 2018
1 parent d730ac6 commit 66ff0a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/cdk-build-tools/bin/cdk-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ async function main() {
desc: 'Specify a different tsc executable',
defaultDescription: 'tsc provided by node dependencies'
})
.option('nyc', {
type: 'string',
desc: 'Specify a different nyc executable',
default: require.resolve('nyc/bin/nyc'),
defaultDescription: 'nyc provided by node dependencies'
})
.option('nodeunit', {
type: 'string',
desc: 'Specify a different nodeunit executable',
default: require.resolve('nodeunit/bin/nodeunit'),
defaultDescription: 'nodeunit provided by node dependencies'
})
.argv as any;

// Always recompile before running tests, so it's impossible to forget.
Expand All @@ -53,9 +65,9 @@ async function main() {
// It's okay if the symlink already exists
if (e.code !== 'EEXIST') { throw e; }
}
testCommand.push(...['nyc', '--clean']);
testCommand.push(...[args.nyc, '--clean']);
}
testCommand.push('nodeunit');
testCommand.push(args.nodeunit);
testCommand.push(...testFiles.map(f => f.path));

await shell(testCommand, timers);
Expand Down
2 changes: 2 additions & 0 deletions tools/cdk-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"jsii": "^0.7.6",
"jsii-pacmak": "^0.7.6",
"merkle-build": "^0.10.0",
"nodeunit": "^0.11.3",
"nyc": "^13.0.1",
"typescript": "^3.0.1",
"yargs": "^9.0.1"
},
Expand Down

0 comments on commit 66ff0a8

Please sign in to comment.