Skip to content

Commit

Permalink
fix(core): fix workspace creation not working on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored and bekos committed Feb 3, 2021
1 parent 34781a1 commit 82ee322
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions packages/devkit/src/tasks/install-packages-task.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Tree } from '@nrwl/tao/src/shared/tree';
import { execSync } from 'child_process';
import { getPackageManagerCommand } from '@nrwl/tao/src/shared/package-manager';
import { join } from 'path';
import {
detectPackageManager,
getPackageManagerCommand,
} from '@nrwl/tao/src/shared/package-manager';

import { joinPathFragments } from '../utils/path';

let storedPackageJsonValue;

Expand All @@ -15,18 +19,26 @@ let storedPackageJsonValue;
export function installPackagesTask(
host: Tree,
alwaysRun: boolean = false,
cwd: string = ''
cwd: string = '',
packageManager?: string
) {
const packageJsonValue = host.read(join(cwd, 'package.json')).toString();
const packageJsonValue = host
.read(joinPathFragments(cwd, 'package.json'))
.toString();
if (
host.listChanges().find((f) => f.path === join(cwd, 'package.json')) ||
host
.listChanges()
.find((f) => f.path === joinPathFragments(cwd, 'package.json')) ||
alwaysRun
) {
if (storedPackageJsonValue != packageJsonValue || alwaysRun) {
storedPackageJsonValue = host.read(join(cwd, 'package.json')).toString();
const pmc = getPackageManagerCommand();
storedPackageJsonValue = host
.read(joinPathFragments(cwd, 'package.json'))
.toString();
const pm = packageManager || detectPackageManager(cwd);
const pmc = getPackageManagerCommand(pm);
execSync(pmc.install, {
cwd: join(host.root, cwd),
cwd: joinPathFragments(host.root, cwd),
stdio: [0, 1, 2],
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/generators/new/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export async function newGenerator(host: Tree, options: Schema) {

await formatFiles(host);
return async () => {
installPackagesTask(host, false, options.directory);
installPackagesTask(host, false, options.directory, options.packageManager);
await generatePreset(host, options);
if (!options.skipGit) {
await initializeGitRepo(host, options.directory, options);
Expand Down

0 comments on commit 82ee322

Please sign in to comment.