Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 74a61e7

Browse files
beemanFrozenPandaz
authored andcommittedAug 18, 2020
fix(core): create-nx-workspace preset and cli params should work with spaces
1 parent fdd9099 commit 74a61e7

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed
 

‎packages/create-nx-workspace/bin/create-nx-workspace.ts

+21-22
Original file line numberDiff line numberDiff line change
@@ -404,26 +404,25 @@ function createApp(
404404
interactive: boolean,
405405
defaultBase: string
406406
) {
407-
// creating the app itself
408-
const args = [
409-
name,
410-
...process.argv
411-
.slice(parsedArgs._[2] ? 3 : 2)
412-
.filter(
413-
(a) =>
414-
!a.startsWith('--cli') &&
415-
!a.startsWith('--preset') &&
416-
!a.startsWith('--appName') &&
417-
!a.startsWith('--app-name') &&
418-
!a.startsWith('--style') &&
419-
!a.startsWith('--nxCloud') &&
420-
!a.startsWith('--nx-cloud') &&
421-
!a.startsWith('--interactive') &&
422-
!a.startsWith('--defaultBase') &&
423-
!a.startsWith('--default-base')
424-
) // not used by the new command
425-
.map((a) => `"${a}"`),
426-
].join(' ');
407+
const filterArgs = [
408+
'_',
409+
'app-name',
410+
'appName',
411+
'cli',
412+
'default-base',
413+
'defaultBase',
414+
'interactive',
415+
'nx-cloud',
416+
'nxCloud',
417+
'preset',
418+
'style',
419+
];
420+
421+
// These are the arguments that are passed to the schematic
422+
const args = Object.keys(parsedArgs)
423+
.filter((key) => !filterArgs.includes(key))
424+
.map((key) => `--${key}=${parsedArgs[key]}`)
425+
.join(' ');
427426

428427
const appNameArg = appName ? ` --appName="${appName}"` : ``;
429428
const styleArg = style ? ` --style="${style}"` : ``;
@@ -434,7 +433,7 @@ function createApp(
434433
const defaultBaseArg = defaultBase ? ` --defaultBase="${defaultBase}"` : ``;
435434

436435
console.log(
437-
`new ${args} --preset="${preset}"${appNameArg}${styleArg}${nxCloudArg}${interactiveArg}${defaultBaseArg} --collection=@nrwl/workspace`
436+
`new ${name} ${args} --preset="${preset}"${appNameArg}${styleArg}${nxCloudArg}${interactiveArg}${defaultBaseArg} --collection=@nrwl/workspace`
438437
);
439438
const executablePath = path.join(tmpDir, 'node_modules', '.bin', cli.command);
440439
const collectionJsonPath = path.join(
@@ -445,7 +444,7 @@ function createApp(
445444
'collection.json'
446445
);
447446
execSync(
448-
`"${executablePath}" new ${args} --preset="${preset}"${appNameArg}${styleArg}${nxCloudArg}${interactiveArg}${defaultBaseArg} --collection=${collectionJsonPath}`,
447+
`"${executablePath}" new ${name} ${args} --preset="${preset}"${appNameArg}${styleArg}${nxCloudArg}${interactiveArg}${defaultBaseArg} --collection=${collectionJsonPath}`,
449448
{
450449
stdio: [0, 1, 2],
451450
}

0 commit comments

Comments
 (0)
Please sign in to comment.