[plugin-helpers] fix order of arguments passed to commander actions (#17663)

This commit is contained in:
Spencer 2018-04-11 12:20:18 -07:00 committed by GitHub
parent 6c1bf403e2
commit 9bbf8ce12e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -30,11 +30,12 @@ Array [
"taskName",
Object {
"args": Array [
"f",
"a",
"b",
"c",
"d",
"e",
"f",
],
},
],

View file

@ -1,9 +1,11 @@
const run = require('./run');
module.exports = function createCommanderAction(taskName, getOptions = () => {}) {
return async (command, ...args) => {
return async (...args) => {
try {
await run(taskName, getOptions(...args));
// command is the last arg passed by commander, but we move it to the front of the list
const command = args.pop();
await run(taskName, getOptions(command, ...args));
} catch (error) {
process.stderr.write(`Task "${taskName}" failed:\n\n${error.stack || error.message}\n`);
process.exit(1);