Skip to content

Commit

Permalink
Merge pull request #29152 from storybookjs/valentin/fix-package-manag…
Browse files Browse the repository at this point in the history
…er-addition-to-package-json

Core: Do not add packageManager field to package.json during `storybook dev`
(cherry picked from commit 57ee6e1)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Sep 19, 2024
1 parent 9c9fb26 commit 499882a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions code/core/src/common/js-package-manager/JsPackageManagerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,35 @@ export class JsPackageManagerFactory {
}

function hasNPM(cwd?: string) {
const npmVersionCommand = spawnSync('npm', ['--version'], { cwd, shell: true });
const npmVersionCommand = spawnSync('npm', ['--version'], {
cwd,
shell: true,
env: {
COREPACK_ENABLE_STRICT: '0',
},
});
return npmVersionCommand.status === 0;
}

function hasPNPM(cwd?: string) {
const pnpmVersionCommand = spawnSync('pnpm', ['--version'], { cwd, shell: true });
const pnpmVersionCommand = spawnSync('pnpm', ['--version'], {
cwd,
shell: true,
env: {
COREPACK_ENABLE_STRICT: '0',
},
});
return pnpmVersionCommand.status === 0;
}

function getYarnVersion(cwd?: string): 1 | 2 | undefined {
const yarnVersionCommand = spawnSync('yarn', ['--version'], { cwd, shell: true });
const yarnVersionCommand = spawnSync('yarn', ['--version'], {
cwd,
shell: true,
env: {
COREPACK_ENABLE_STRICT: '0',
},
});

if (yarnVersionCommand.status !== 0) {
return undefined;
Expand Down

0 comments on commit 499882a

Please sign in to comment.