Skip to content

Commit

Permalink
fix(core): ensure preinstall is only run once on repo (#18671)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Aug 18, 2023
1 parent 195c5bf commit adb39c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 0 additions & 3 deletions packages/devkit/src/tasks/install-packages-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export function installPackagesTask(
cwd: join(tree.root, cwd),
stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
};
if (pmc.preInstall) {
execSync(pmc.preInstall, execSyncOptions);
}
execSync(pmc.install, execSyncOptions);
}
}
10 changes: 10 additions & 0 deletions packages/workspace/src/generators/new/new.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
addDependenciesToPackageJson,
getPackageManagerCommand,
installPackagesTask,
joinPathFragments,
names,
PackageManager,
Tree,
Expand All @@ -11,6 +13,7 @@ import { Preset } from '../utils/presets';
import { Linter } from '../../utils/lint';
import { generateWorkspaceFiles } from './generate-workspace-files';
import { addPresetDependencies, generatePreset } from './generate-preset';
import { execSync } from 'child_process';

interface Schema {
directory: string;
Expand Down Expand Up @@ -48,6 +51,13 @@ export async function newGenerator(host: Tree, opts: Schema) {
addCloudDependencies(host, options);

return async () => {
const pmc = getPackageManagerCommand(options.packageManager);
if (pmc.preInstall) {
execSync(pmc.preInstall, {
cwd: joinPathFragments(host.root, options.directory),
stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
});
}
installPackagesTask(host, false, options.directory, options.packageManager);
// TODO: move all of these into create-nx-workspace
if (
Expand Down

1 comment on commit adb39c4

@vercel
Copy link

@vercel vercel bot commented on adb39c4 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.