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

This commit is contained in:
Spencer 2018-04-11 13:20:03 -07:00 committed by GitHub
parent 8c10e9d1e0
commit 3bf90dc9f1
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);