Skip to content

Commit 718227c

Browse files
author
Robert Jackson
authored
Merge pull request #254 from SergeAstapov/patch-2
2 parents 653a5f4 + e19d026 commit 718227c

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

.github/workflows/nodejs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
yarn-version: 1.22.4
25+
- name: Install pnpm
26+
uses: pnpm/[email protected]
27+
with:
28+
version: 6.32.3
2529
- run: yarn install --frozen-lockfile
2630
- run: yarn lint:js
2731
- run: yarn test

__tests__/bin-test.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,18 @@ describe('main binary', function () {
471471
});
472472

473473
describe('RELEASE.md', function () {
474-
function expectedReleaseContents(isYarn) {
474+
function expectedReleaseContents(packageManager = 'npm') {
475475
let releaseContents = fs.readFileSync(path.join(__dirname, '..', 'release-template.md'), {
476476
encoding: 'utf8',
477477
});
478478

479-
let dependencyInstallReplacementValue = isYarn ? 'yarn install' : 'npm install';
479+
let dependencyInstallReplacementValue = `${packageManager} install`;
480+
let releaseCommandReplacementValue =
481+
packageManager === 'pnpm' ? 'pnpm exec release-it' : 'npx release-it';
480482

481-
return releaseContents.replace('{{INSTALL_DEPENDENCIES}}', dependencyInstallReplacementValue);
483+
return releaseContents
484+
.replace('{{INSTALL_DEPENDENCIES}}', dependencyInstallReplacementValue)
485+
.replace('{{RELEASE_COMMAND}}', releaseCommandReplacementValue);
482486
}
483487

484488
it('adds RELEASE.md to repo when no yarn.lock exists', async function () {
@@ -487,7 +491,7 @@ describe('main binary', function () {
487491
await exec(['--no-install', '--no-label-updates']);
488492

489493
expect(fs.readFileSync('RELEASE.md', { encoding: 'utf8' })).toBe(
490-
expectedReleaseContents(false)
494+
expectedReleaseContents('npm')
491495
);
492496
});
493497

@@ -499,7 +503,19 @@ describe('main binary', function () {
499503
await exec(['--no-install', '--no-label-updates']);
500504

501505
expect(fs.readFileSync('RELEASE.md', { encoding: 'utf8' })).toBe(
502-
expectedReleaseContents(true)
506+
expectedReleaseContents('yarn')
507+
);
508+
});
509+
510+
it('adds RELEASE.md to repo when pnpm-lock.yaml exists', async function () {
511+
fs.writeFileSync('pnpm-lock.yaml', '', { encoding: 'utf-8' });
512+
513+
expect(fs.existsSync('RELEASE.md')).toBeFalsy();
514+
515+
await exec(['--no-install', '--no-label-updates']);
516+
517+
expect(fs.readFileSync('RELEASE.md', { encoding: 'utf8' })).toBe(
518+
expectedReleaseContents('pnpm')
503519
);
504520
});
505521

@@ -515,7 +531,18 @@ describe('main binary', function () {
515531
await exec(['--no-install', '--no-label-updates', '--update']);
516532

517533
expect(fs.readFileSync('RELEASE.md', { encoding: 'utf8' })).toBe(
518-
expectedReleaseContents(true)
534+
expectedReleaseContents('yarn')
535+
);
536+
});
537+
538+
it('updates RELEASE.md when pnpm-lock.yaml exists', async function () {
539+
fs.writeFileSync('pnpm-lock.yaml', '', { encoding: 'utf-8' });
540+
fs.writeFileSync('RELEASE.md', 'lololol', 'utf8');
541+
542+
await exec(['--no-install', '--no-label-updates', '--update']);
543+
544+
expect(fs.readFileSync('RELEASE.md', { encoding: 'utf8' })).toBe(
545+
expectedReleaseContents('pnpm')
519546
);
520547
});
521548

@@ -525,7 +552,7 @@ describe('main binary', function () {
525552
await exec(['--no-install', '--no-label-updates', '--update']);
526553

527554
expect(fs.readFileSync('RELEASE.md', { encoding: 'utf8' })).toBe(
528-
expectedReleaseContents(false)
555+
expectedReleaseContents('npm')
529556
);
530557
});
531558

bin/rwjblue-release-it-setup.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,19 @@ function isYarn() {
212212
return fs.existsSync('yarn.lock');
213213
}
214214

215+
function isPnpm() {
216+
return fs.existsSync('pnpm-lock.yaml');
217+
}
218+
215219
async function installDependencies() {
216220
if (labelsOnly || skipInstall) {
217221
return;
218222
}
219223

220224
if (isYarn()) {
221225
await execa('yarn');
226+
} else if (isPnpm()) {
227+
await execa('pnpm', ['install']);
222228
} else {
223229
await execa('npm', ['install']);
224230
}
@@ -258,11 +264,17 @@ async function main() {
258264
encoding: 'utf8',
259265
});
260266

261-
let dependencyInstallReplacementValue = isYarn() ? 'yarn install' : 'npm install';
267+
let dependencyInstallReplacementValue = `${
268+
isYarn() ? 'yarn' : isPnpm() ? 'pnpm' : 'npm'
269+
} install`;
270+
271+
let releaseCommandReplacementValue = isPnpm() ? 'pnpm exec release-it' : 'npx release-it';
262272

263273
fs.writeFileSync(
264274
'RELEASE.md',
265-
releaseContents.replace('{{INSTALL_DEPENDENCIES}}', dependencyInstallReplacementValue),
275+
releaseContents
276+
.replace('{{INSTALL_DEPENDENCIES}}', dependencyInstallReplacementValue)
277+
.replace('{{RELEASE_COMMAND}}', releaseCommandReplacementValue),
266278
{ encoding: 'utf8' }
267279
);
268280
}

release-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Once the prep work is completed, the actual release is straight forward:
5050
* And last (but not least 😁) do your release.
5151

5252
```sh
53-
npx release-it
53+
{{RELEASE_COMMAND}}
5454
```
5555

5656
[release-it](https://github.com/release-it/release-it/) manages the actual

0 commit comments

Comments
 (0)