Skip to content

Commit 8b5aeb4

Browse files
authored
Merge pull request #765 from postmanlabs/fix/proper-installation-support-for-package-mangers
[Fix] Added proper installation support for various node package managers
2 parents 8987d53 + 123d0c8 commit 8b5aeb4

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

npm/ci-requirements.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pushd ./codegens/csharp-restsharp &>/dev/null;
3939
sudo apt-get install dotnet-sdk-6.0
4040
dotnet new console -o testProject -f net6.0
4141
pushd ./testProject &>/dev/null;
42-
dotnet add package RestSharp --version 110.0.0
42+
dotnet add package RestSharp --version 112.0.0
4343
popd &>/dev/null;
4444
popd &>/dev/null;
4545

npm/deepinstall.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
var shell = require('shelljs'),
22
path = require('path'),
33
async = require('async'),
4-
{ detect } = require('detect-package-manager'),
4+
{ detect, getNpmVersion } = require('detect-package-manager'),
55
pm,
6-
PRODUCTION_FLAG = '',
6+
ver,
7+
command,
78
getSubfolders,
89
fs = require('fs'),
910
pwd = shell.pwd();
@@ -24,12 +25,34 @@ async.series([
2425
return next();
2526
});
2627
},
28+
function (next) {
29+
getNpmVersion(pm).then((res) => {
30+
ver = res;
31+
console.log('Detected ' + pm + ' version: ' + ver);
32+
return next();
33+
});
34+
},
2735
function (next) {
2836
if (args[2] && args[2] === 'dev') {
2937
console.log('Dev flag detected running ' + pm + ' install');
38+
command = pm + ' install';
3039
}
3140
else {
32-
PRODUCTION_FLAG = '--no-audit --production';
41+
switch (pm) {
42+
case 'yarn':
43+
if (ver.startsWith('1')) {
44+
command = 'yarn install --production --frozen-lockfile';
45+
}
46+
else {
47+
command = 'touch yarn.lock && yarn workspaces focus --all --production'
48+
}
49+
break;
50+
case 'pnpm':
51+
command = 'pnpm install --prod';
52+
break;
53+
default:
54+
command = pm + ' install --no-audit --production';
55+
}
3356
}
3457

3558
console.log('Running pre-package script');
@@ -51,8 +74,8 @@ async.series([
5174

5275
var commandOut;
5376

54-
console.log(codegen.name + ': ' + pm + ' install ' + PRODUCTION_FLAG);
55-
commandOut = shell.exec(pm + ' install ' + PRODUCTION_FLAG, { silent: true });
77+
console.log(codegen.name + ': ' + command);
78+
commandOut = shell.exec(command, { silent: true });
5679

5780
if (commandOut.code !== 0) {
5881
console.error('Failed to run ' + pm + ' install on codegen ' + codegen.name + ', here is the error:');

0 commit comments

Comments
 (0)