Skip to content

Commit

Permalink
fix: nyc path subtly different with new yarn, require relative to cwd
Browse files Browse the repository at this point in the history
this should be backwards-compatible with the previous lookup style, but
also works correctly with new yarn

if not, and there is a problem (either with existing users or in the future)
it now attempts to print out a helpful message indicating why it failed and
where it looked
  • Loading branch information
mikehardy committed Feb 4, 2025
1 parent 0f04760 commit 57565fc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/usr/bin/env node
const fs = require('fs');

if (process.argv.includes('--coverage') && !process.env.NYC_CONFIG) {
process.argv.unshift(require.resolve('./node_modules/.bin/nyc'));
require('./node_modules/.bin/nyc');
const nycPath = `${process.cwd()}/node_modules/.bin/nyc`;
if (!fs.existsSync(nycPath)) {
throw Error(
`Jet: '--coverage' requested but cannot find 'nyc'. Did not run from app root? Looked in: '${nycPath}'`
);
}

process.argv.unshift(require.resolve(nycPath));
require(nycPath);
} else {
require('./lib/commonjs/cli.js');
}

0 comments on commit 57565fc

Please sign in to comment.