Skip to content

Commit

Permalink
fix(nx): fix workspace schematic package manager detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Aug 10, 2019
1 parent 4e0602a commit bd7af85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function showCliWarning(preset: string, parsedArgs: any) {
) {
output.addVerticalSeparator();
output.note({
title: `We generated an Nx workspace powered by the Nx CLi.`,
title: `We generated an Nx workspace powered by the Nx CLI.`,
bodyLines: [
`Run 'create-nx-workspace --help' to see how to select a different CLI.`
]
Expand Down
14 changes: 10 additions & 4 deletions packages/workspace/src/command-line/workspace-schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as yargsParser from 'yargs-parser';
import { fileExists } from '../utils/fileutils';
import { appRootPath } from '../utils/app-root';
import { output } from './output';
import { platform } from 'os';

const rootDirectory = appRootPath;

Expand Down Expand Up @@ -73,8 +74,12 @@ function getToolsOutDir() {

function compileToolsDir(outDir: string) {
copySync(path.join(rootDirectory, 'tools'), outDir);
const tsc =
platform() === 'win32'
? `.\\node_modules\\.bin\\tsc`
: `./node_modules/.bin/tsc`;
try {
execSync('tsc -p tools/tsconfig.tools.json', {
execSync(`${tsc} -p tools/tsconfig.tools.json`, {
stdio: 'inherit',
cwd: rootDirectory
});
Expand Down Expand Up @@ -125,12 +130,13 @@ function createWorkflow(dryRun: boolean) {

function detectPackageManager(): string {
try {
const packageManager = execSync(`nx config cli.packageManager`, {
const output = execSync(`nx config cli.packageManager`, {
stdio: ['ignore', 'pipe', 'ignore']
})
.toString()
.trim();
return packageManager;
.trim()
.split('\n');
return output[output.length - 1].trim();
} catch (e) {
return fileExists('yarn.lock')
? 'yarn'
Expand Down

0 comments on commit bd7af85

Please sign in to comment.