Skip to content

Commit 46d35ae

Browse files
feat: add pnpm as optional package manager (#1020)
1 parent eae7346 commit 46d35ae

File tree

17 files changed

+360
-24
lines changed

17 files changed

+360
-24
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ This is for adding a module to be included in the default `citgm-all` runs.
5252
- Module source code must be on Github.
5353
- Published versions must include a tag on Github
5454
- The test process must be executable with only the commands
55-
`npm install && npm test` or (`yarn install && yarn test`) using the tarball
55+
`npm install && npm test` or (`yarn install && yarn test`
56+
or `pnpm install && pnpm test`) using the tarball
5657
downloaded from the Github tag mentioned above
5758
- The tests pass on supported major release lines
5859
- The maintainers of the module remain responsive when there are problems

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Options:
109109
--excludeTags tag1 tag2 Specify which tags to skip from the lookup (takes priority over includeTags)
110110
Module names are automatically added as tags.
111111
-y, --yarn Install and test the project using yarn instead of npm
112+
--pnpm Install and test the project using pnpm instead of npm
112113
```
113114

114115
When using a JSON config file, the properties need to be the same as the
@@ -134,13 +135,14 @@ For syntax, see [lookup.json](./lib/lookup.json), the available attributes are:
134135
"stripAnsi": true Strip ansi data from output stream of npm
135136
"sha": "<git-commit-sha>" Test against a specific commit
136137
"envVar" Pass an environment variable before running
137-
"install": ["install", "--param1", "--param2"] - Array of command line parameters passed to 'npm' or 'yarn' as install arguments
138+
"install": ["install", "--param1", "--param2"] - Array of command line parameters passed to `npm` or `yarn` or `pnpm` as install arguments
138139
"maintainers": ["user1", "user2"] - List of module maintainers to be contacted with issues
139140
"scripts": ["script1", "script2"] - List of scripts from package.json to run instead of 'test'
140141
"tags": ["tag1", "tag2"] Specify which tags apply to the module
141142
"useGitClone": true Use a shallow git clone instead of downloading the module
142143
"ignoreGitHead": Ignore the gitHead field if it exists and fallback to using github tags
143144
"yarn": Install and test the project using yarn instead of npm
145+
"pnpm": Install and test the project using pnpm instead of npm
144146
"timeout": Number of milliseconds before timeout. Applies separately to `install` and `test`
145147
```
146148

lib/bin/citgm-all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const options = {
6969
tmpDir: app.tmpDir,
7070
customTest: app.customTest,
7171
yarn: app.yarn,
72+
pnpm: app.pnpm,
7273
includeTags: app.includeTags || [],
7374
excludeTags: app.excludeTags || []
7475
};

lib/bin/citgm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const options = {
4545
sha: app.sha,
4646
tmpDir: app.tmpDir,
4747
customTest: app.customTest,
48-
yarn: app.yarn
48+
yarn: app.yarn,
49+
pnpm: app.pnpm
4950
};
5051

5152
if (!windows) {

lib/citgm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ export class Tester extends EventEmitter {
8989
init(this);
9090
await findNode(this);
9191

92-
const { npm, yarn } = await getPackageManagers();
92+
const { npm, yarn, pnpm } = await getPackageManagers();
9393
this.npmPath = npm;
9494
this.yarnPath = yarn;
95+
this.pnpmPath = pnpm;
9596

9697
await tempDirectory.create(this);
9798
await grabModuleData(this);

lib/common-args.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export function commonArgs() {
8282
description: 'Install and test the project using yarn instead of npm',
8383
default: false
8484
})
85+
.option('pnpm', {
86+
type: 'boolean',
87+
description: 'Install and test the project using pnpm instead of npm',
88+
default: false
89+
})
8590
.example(
8691
'citgm-all --customTest /path/to/customTest.js',
8792
'Runs a custom node test script instead of "npm test"'

lib/grab-project.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ export async function grabProject(context) {
1717
}
1818

1919
return new Promise((resolve, reject) => {
20-
const packageManager =
21-
context.options.yarn || context.module.useYarn ? 'yarn' : 'npm';
20+
let packageManager = 'npm';
21+
if (context.options.yarn || context.module.useYarn) {
22+
packageManager = 'yarn';
23+
} else if (context.options.pnpm || context.module.usePnpm) {
24+
packageManager = 'pnpm';
25+
}
2226
let packageName = context.module.raw;
2327
if (context.module.type === 'directory') {
2428
context.module.raw = context.module.name = path.basename(packageName);

lib/lookup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ export function lookup(context) {
183183
if (rep.yarn) {
184184
context.module.useYarn = true;
185185
}
186+
if (rep.pnpm) {
187+
context.module.usePnpm = true;
188+
}
186189
if (rep.timeout) {
187190
context.module.timeout = rep.timeout;
188191
}

lib/package-manager/get-executable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const npmWhich = promisify(
1010
);
1111

1212
export function getExecutable(binaryName) {
13-
if (binaryName === 'yarn') {
14-
// Use `npm-which` for yarn to get the local version
13+
if (binaryName === 'yarn' || binaryName === 'pnpm') {
14+
// Use `npm-which` for yarn or pnpm to get the local version
1515
return npmWhich(binaryName);
1616
} else {
1717
return which(binaryName);

lib/package-manager/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { getExecutable } from './get-executable.js';
55
export function pkgInstall(context) {
66
if (context.options.yarn || context.module.useYarn) {
77
return install('yarn', context);
8+
} else if (context.options.pnpm || context.module.usePnpm) {
9+
return install('pnpm', context);
810
} else {
911
return install('npm', context);
1012
}
@@ -13,15 +15,18 @@ export function pkgInstall(context) {
1315
export function pkgTest(context) {
1416
if (context.options.yarn || context.module.useYarn) {
1517
return test('yarn', context);
18+
} else if (context.options.pnpm || context.module.usePnpm) {
19+
return test('pnpm', context);
1620
} else {
1721
return test('npm', context);
1822
}
1923
}
2024

2125
export async function getPackageManagers() {
22-
const [npm, yarn] = await Promise.all([
26+
const [npm, yarn, pnpm] = await Promise.all([
2327
getExecutable('npm'),
24-
getExecutable('yarn')
28+
getExecutable('yarn'),
29+
getExecutable('pnpm')
2530
]);
26-
return { npm, yarn };
31+
return { npm, yarn, pnpm };
2732
}

0 commit comments

Comments
 (0)