Skip to content

Commit 671e88a

Browse files
authored
fix(build): fix list of files expected to be unchanged for releases (#1651)
Before publishing to npm, lerna ensures that the working tree is in a clean state (no unchanged or uncommitted files). Our logic to make `git` assume that files were unchanged was broken for a few files, in particular the top-level package.json and the `.nvm` directory that we now place under the `.evergreen/` folder in the repository rather than a temporary path.
1 parent 7c5be11 commit 671e88a

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ tmp/
2323
dist.tgz
2424
compiled-ts.tgz
2525
mongocryptd.pid
26-
.sbom
26+
.sbom
27+
.nvm

packages/build/src/npm-packages/list.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ describe('npm-packages list', function () {
2626
beforeEach(function () {
2727
expectedFiles = [
2828
path.resolve(__dirname, '..', '..', '..', '..', 'lerna.json'),
29+
path.resolve(__dirname, '..', '..', '..', '..', 'package.json'),
30+
path.resolve(__dirname, '..', '..', '..', '..', 'package-lock.json'),
2931
];
3032
packages = listNpmPackages();
31-
packages.forEach(({ location }) => {
33+
for (const { location } of packages) {
3234
expectedFiles.push(path.resolve(location, 'package.json'));
33-
expectedFiles.push(path.resolve(location, 'package-lock.json'));
34-
});
35+
}
3536

3637
spawnSync = sinon.stub();
3738
});

packages/build/src/npm-packages/publish.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ export function markBumpedFilesAsAssumeUnchanged(
6161
assumeUnchanged: boolean,
6262
spawnSyncFn: typeof spawnSync = spawnSync
6363
): void {
64-
const filesToAssume = [path.resolve(PROJECT_ROOT, 'lerna.json')];
65-
packages.forEach(({ location }) => {
64+
const filesToAssume = [
65+
path.resolve(PROJECT_ROOT, 'lerna.json'),
66+
path.resolve(PROJECT_ROOT, 'package.json'),
67+
path.resolve(PROJECT_ROOT, 'package-lock.json'),
68+
];
69+
for (const { location } of packages) {
6670
filesToAssume.push(path.resolve(location, 'package.json'));
67-
filesToAssume.push(path.resolve(location, 'package-lock.json'));
68-
});
71+
}
6972

70-
filesToAssume.forEach((f) => {
73+
for (const f of filesToAssume) {
7174
spawnSyncFn(
7275
'git',
7376
[
@@ -85,5 +88,5 @@ export function markBumpedFilesAsAssumeUnchanged(
8588
console.info(
8689
`File ${f} is now ${assumeUnchanged ? '' : 'NOT '}assumed to be unchanged`
8790
);
88-
});
91+
}
8992
}

0 commit comments

Comments
 (0)