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
(cherry picked from commit adb39c4)
  • Loading branch information
meeroslav authored and FrozenPandaz committed Aug 21, 2023
1 parent b024f44 commit 426e3aa
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

0 comments on commit 426e3aa

Please # to comment.