Skip to content

Commit

Permalink
Place async hook / action warning better
Browse files Browse the repository at this point in the history
  • Loading branch information
aweebit committed Jul 29, 2023
1 parent dfe2fc7 commit 3572657
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,11 @@ Call on top-level command instead`);

parse(argv, parseOptions) {
return this._parseSubroutine(false, (userArgs) => {
this._parseCommand([], userArgs);
const result = this._parseCommand([], userArgs);
if (!PRODUCTION && isThenable(result)) {
console.warn(`.parse() is incompatible with async hooks and actions.

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 16.x and ubuntu-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 16.x and windows-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 16.x and ubuntu-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 16.x and macos-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 16.x and windows-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 18.x and ubuntu-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 16.x and macos-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 18.x and windows-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 18.x and ubuntu-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 18.x and macos-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 18.x and windows-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 20.x and ubuntu-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 18.x and macos-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 20.x and windows-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 20.x and ubuntu-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 20.x and macos-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 20.x and windows-latest

Expected indentation of 8 spaces but found 6

Check failure on line 942 in lib/command.js

View workflow job for this annotation

GitHub Actions / Test on node 20.x and macos-latest

Expected indentation of 8 spaces but found 6
Use .parseAsync() instead.`);
}
return this;
}, argv, parseOptions);
}
Expand Down Expand Up @@ -1220,19 +1224,12 @@ Call on top-level command instead`);
*/

_chainOrCall(promise, fn) {
// thenable
if (isThenable(promise)) {
// already have a promise, chain callback
return promise.then(() => fn());
}

// callback might return a promise
const result = fn();
if (!PRODUCTION && !this._asyncParsing && isThenable(result)) {
console.warn(`.parse() is incompatible with async hooks and actions.
Use .parseAsync() instead.`);
}
return result;
return fn();
}

/**
Expand Down

0 comments on commit 3572657

Please sign in to comment.