Skip to content

Commit 4199377

Browse files
committed
Adds env var for package manager to run scripts
1 parent 40bbac1 commit 4199377

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

webpack.config.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const eslintWorker = {
3838
filesPerWorker: 100,
3939
};
4040

41+
const useNpm = Boolean(process.env.GL_USE_NPM);
42+
if (useNpm) {
43+
console.log('Using npm to run scripts');
44+
}
45+
46+
const pkgMgr = useNpm ? 'npm' : 'pnpm';
47+
4148
/**
4249
* @param {{ analyzeBundle?: boolean; analyzeDeps?: boolean; esbuild?: boolean; skipLint?: boolean } | undefined } env
4350
* @param {{ mode: 'production' | 'development' | 'none' | undefined }} argv
@@ -119,13 +126,13 @@ function getExtensionConfig(target, mode, env) {
119126
mode !== 'production'
120127
? undefined
121128
: () =>
122-
spawnSync('pnpm', ['run', 'icons:svgo'], {
129+
spawnSync(pkgMgr, ['run', 'icons:svgo'], {
123130
cwd: __dirname,
124131
encoding: 'utf8',
125132
shell: true,
126133
}),
127134
onComplete: () =>
128-
spawnSync('pnpm', ['run', 'icons:apply'], {
135+
spawnSync(pkgMgr, ['run', 'icons:apply'], {
129136
cwd: __dirname,
130137
encoding: 'utf8',
131138
shell: true,
@@ -825,7 +832,7 @@ class ContributionsPlugin extends FileGeneratorPlugin {
825832
constructor() {
826833
super('contributions', [path.join(__dirname, 'contributions.json')], {
827834
name: "'package.json' contributions",
828-
command: 'pnpm',
835+
command: pkgMgr,
829836
args: ['run', 'generate:contributions'],
830837
});
831838
}
@@ -835,7 +842,7 @@ class DocsPlugin extends FileGeneratorPlugin {
835842
constructor() {
836843
super('docs', [path.join(__dirname, 'src', 'constants.telemetry.ts')], {
837844
name: 'docs',
838-
command: 'pnpm',
845+
command: pkgMgr,
839846
args: ['run', 'generate:docs:telemetry'],
840847
});
841848
}

0 commit comments

Comments
 (0)