Skip to content

Commit

Permalink
Add backwards compatibility for positional args (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
karaggeorge authored Aug 12, 2020
1 parent 247b285 commit 3daf602
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ const getCommandsMessage = command => {
return `Commands:\n${command.subCommands.map(subCommand => ` ${usageString} ${subCommand.name}`).join('\n')}\n`;
};

module.exports = (dirname, React, Ink, commands) => {
module.exports = (dirname, React, Ink, originalCommands) => {
let commands = originalCommands;

// For backwards compatibility for builds made with versions prior to 1.1.0 that don't include positionalArgs
if (originalCommands.some(command => !command.positionalArgs && (command.args || []).some(arg => arg.positional))) {
commands = originalCommands.map(command => ({
...command,
positionalArgs: (command.args || []).filter(arg => arg.positional).map(arg => arg.key)
}));
}

const addCommand = (command, yargs) => {
// Don't need to add a description as it'll be handled by the * selector in the builder
// eslint-disable-next-line no-use-before-define
Expand Down

0 comments on commit 3daf602

Please sign in to comment.