Skip to content

Commit

Permalink
feat(nx): when creating a nx workspace try to use the same package ma…
Browse files Browse the repository at this point in the history
…nager as Angular CLI

create-nx-workspace now prefers to use the package manager configured in global angular.json.
  • Loading branch information
mbinic authored and vsavkin committed Jun 15, 2019
1 parent bf624b7 commit 26903c0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
26 changes: 18 additions & 8 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@ const nxTool = {
name: 'Schematics',
packageName: '@nrwl/workspace'
};
let useYarn = true;

let packageManager: string;
try {
execSync('yarn --version', { stdio: ['ignore', 'ignore', 'ignore'] });
packageManager = execSync('ng config -g cli.packageManager', {
stdio: ['ignore', 'pipe', 'ignore']
})
.toString()
.trim();
} catch (e) {
packageManager = 'yarn';
}
try {
execSync(`${packageManager} --version`, {
stdio: ['ignore', 'ignore', 'ignore']
});
} catch (e) {
useYarn = false;
packageManager = 'npm';
}

const projectName = parsedArgs._[2];
Expand Down Expand Up @@ -69,11 +80,10 @@ writeFileSync(
})
);

if (useYarn) {
execSync('yarn install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
} else {
execSync('npm install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
}
execSync(`${packageManager} install --silent`, {
cwd: tmpDir,
stdio: [0, 1, 2]
});

// creating the app itself
const args = process.argv
Expand Down
26 changes: 18 additions & 8 deletions packages/workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@ const nxTool = {
name: 'Nx Workspace',
packageName: '@nrwl/workspace'
};
let useYarn = true;

let packageManager: string;
try {
execSync('yarn --version', { stdio: ['ignore', 'ignore', 'ignore'] });
packageManager = execSync('ng config -g cli.packageManager', {
stdio: ['ignore', 'pipe', 'ignore']
})
.toString()
.trim();
} catch (e) {
packageManager = 'yarn';
}
try {
execSync(`${packageManager} --version`, {
stdio: ['ignore', 'ignore', 'ignore']
});
} catch (e) {
useYarn = false;
packageManager = 'npm';
}

const projectName = parsedArgs._[2];
Expand Down Expand Up @@ -69,11 +80,10 @@ writeFileSync(
})
);

if (useYarn) {
execSync('yarn install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
} else {
execSync('npm install --silent', { cwd: tmpDir, stdio: [0, 1, 2] });
}
execSync(`${packageManager} install --silent`, {
cwd: tmpDir,
stdio: [0, 1, 2]
});

// creating the app itself
const args = process.argv
Expand Down

0 comments on commit 26903c0

Please sign in to comment.