Skip to content

Commit

Permalink
feat(config): new option testScript
Browse files Browse the repository at this point in the history
support new option `testScript` to customize the NPM script to run the Atom package tests/specs
  • Loading branch information
Carlos García committed Mar 2, 2018
1 parent 5a725c9 commit 8401b52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/instrumenter/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ const nyc = {

/**
* @summary Wraps the NPM `test` script of the Atom package with `nyc`.
* @return {[type]} [description]
* @param {String} testScript The NPM script that runs the Atom package tests.
*/
run() {
run(testScript) {
// We pass all env vars, because `atom --test` needs some ones for this
// cmd to succeed (otherwise it takes `root` as user running the specs).
execSync('nyc npm test', { cwd, env: process.env, stdio: 'inherit' });
execSync(`nyc npm run ${testScript}`, { cwd, env: process.env, stdio: 'inherit' });
},

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const schema = {
.description('The coverage tool to use to collect the coverage info'),
transpiler: Joi.string().optional().default('babel').valid('babel')
.description('The library/framework to use for transpiling the source files into plain JavaScript'),
testScript: Joi.string().optional().default('test')
.description('The NPM script to run the Atom package tests'),
// Internal initialized if missing WHEN reading config through `cosmiconfig`.
sourcesRoot: Joi.string().optional()
.description('The root path for the source files of your project'),
Expand All @@ -31,6 +33,7 @@ const cwd = process.cwd();
const defaults = {
config: {
instrumenter: 'nyc',
testScript: 'test',
transpiler: 'babel',
},
cosmiconfig: {
Expand Down Expand Up @@ -167,7 +170,7 @@ const manager = {
}

// Step 3: run coverage tool.
this.instrumenter.run();
this.instrumenter.run(this.config.testScript);
},

/**
Expand Down

0 comments on commit 8401b52

Please sign in to comment.