Skip to content

Commit

Permalink
[New] automatically detect --multi mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 25, 2024
1 parent 8bf6ae2 commit 4e7f6d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,18 @@ if (moduleNames.length < 1) {
process.exit(2);
}
moduleNames.push([pkg.name + ' (current directory)', [path.join(process.cwd(), pkg.main || ''), process.cwd()]]);

var mainIsJSON = path.extname(require.resolve(process.cwd())) === '.json';
if (isMulti && !mainIsJSON) {
console.error('Error: --multi requires package.json main to be a JSON file');
process.exit(3);
}
if (!isMulti && mainIsJSON) {
isMulti = true;
console.error('# automatic `--multi` mode enabled');
}
}

var requireOrEvalError = function (name) {
try {
return require(name);
Expand Down

0 comments on commit 4e7f6d7

Please sign in to comment.