Skip to content

Commit

Permalink
fix(schematics): handle the case when -a and --app are surrounded by …
Browse files Browse the repository at this point in the history
…quotes
  • Loading branch information
vsavkin committed Dec 21, 2017
1 parent e3feb8a commit be6bfd3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/schematics/src/utils/cli-config-utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as fs from 'fs';

export function getAppDirectoryUsingCliConfig() {
const appOption = process.argv.filter(a => a.startsWith('-a=') || a.startsWith('--app='))[0];
const appArg = findAppArg();
const cli = JSON.parse(fs.readFileSync(process.cwd() + '/.angular-cli.json', 'UTF-8'));

if (appOption) {
const appName = appOption.split('=')[1];
if (appArg) {
const appName = appArg.split('=')[1];
const app = cli.apps.filter(a => a.name === appName)[0];
if (!app) {
console.error(`Cannot find app '${appName}'.`);
Expand All @@ -23,11 +23,22 @@ export function getAppDirectoryUsingCliConfig() {
}

export function makeSureNoAppIsSelected() {
const appOption = process.argv.filter(a => a.startsWith('-a=') || a.startsWith('--app='))[0];
if (appOption) {
if (findAppArg()) {
console.error('Nx only supports running unit tests for all apps and libs.');
console.error('You cannot use -a or --app.');
console.error('Use fdescribe or fit to select a subset of tests to run.');
process.exit(1);
}
}

function findAppArg() {
return process.argv.filter(
a =>
a.startsWith(`-a=`) ||
a.startsWith(`--app=`) ||
a.startsWith(`"-a="`) ||
a.startsWith(`"--app="`) ||
a.startsWith(`'-a='`) ||
a.startsWith(`'--app='`)
)[0];
}

0 comments on commit be6bfd3

Please sign in to comment.