Skip to content

Commit

Permalink
fix: enforce some options as singular only
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Mar 1, 2022
1 parent 44d277d commit b779759
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/nx/src/executors/build/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ export default async function runExecutor(options: BuildBuilderSchema, context:
}
}

// some options should never be duplicated
const enforceSingularOptions = ['provision', 'device', 'copy-to'];
const parseOptionName = (flag: string) => {
// strip just the option name from extra arguments
// --provision='match AppStore my.bundle.com' > provision
return flag.split('=')[0].replace('--', '');
};
// additional cli flags
// console.log('projectTargetCmdIndex:', projectTargetCmdIndex)
const additionalArgs = [];
Expand All @@ -173,7 +180,8 @@ export default async function runExecutor(options: BuildBuilderSchema, context:
// manually added flags to the execution command
const extraFlags = process.argv.slice(projectTargetCmdIndex + 1, process.argv.length);
for (const flag of extraFlags) {
if (!nsOptions.includes(flag) && !additionalArgs.includes(flag)) {
const optionName = parseOptionName(flag);
if (!nsOptions.includes(flag) && !additionalArgs.includes(flag) && !enforceSingularOptions.includes(optionName)) {
additionalArgs.push(flag);
}
}
Expand All @@ -186,7 +194,6 @@ export default async function runExecutor(options: BuildBuilderSchema, context:
console.log(' ');
console.log([`ns`, ...nsOptions, ...additionalArgs].join(' '));
console.log(' ');
// console.log('command:', [`ns`, ...nsOptions].join(' '));
const child = childProcess.spawn(/^win/.test(process.platform) ? 'ns.cmd' : 'ns', [...nsOptions, ...additionalArgs], {
cwd: projectCwd,
stdio: 'inherit',
Expand Down

0 comments on commit b779759

Please sign in to comment.