Skip to content

Commit d5e0242

Browse files
devversionAndrewKushnir
authored andcommitted
build: create script to update integration lock files (angular#49787)
* Adds a small script to conveniently re-generate lock files for integration tests. * Updates the `.gitignore` for integration tests to ignore node modules. Some tests do not have a `.gitignore` (like the CLI boilerplate tests). PR Close angular#49787
1 parent 4238ed8 commit d5e0242

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

integration/.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ tmp/
66
*/src/*.js
77
!karma.conf.js
88
**/.yarn_local_cache*
9-
**/NPM_PACKAGE_MANIFEST.json
9+
**/NPM_PACKAGE_MANIFEST.json
10+
11+
*/node_modules/
12+
13+
.tmp-yarn-cache/

integration/update-lock-files.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that deletes all `yarn.lock` files for integration tests and
5+
* re-builds them from scratch. This script is useful as lock fils in
6+
* integration tests are not necessarily up-to-date, given dependencies
7+
* being linked from the root `/package.json`, or locally-built 1st party
8+
* packages being used from tarball archives.
9+
*/
10+
11+
import childProcess from 'child_process';
12+
import url from 'url';
13+
import path from 'path';
14+
import glob from 'glob';
15+
import fs from 'fs';
16+
17+
const containingDir = path.dirname(url.fileURLToPath(import.meta.url));
18+
const testDirs = glob.sync('*/BUILD.bazel', {cwd: containingDir})
19+
.map((d) => path.join(containingDir, path.dirname(d)));
20+
21+
const yarnTestTmpDir = path.join(containingDir, '.tmp-yarn-cache');
22+
23+
for (const testDir of testDirs) {
24+
fs.rmSync(path.join(testDir, 'yarn.lock'));
25+
childProcess.spawnSync('yarn', ['install', '--cache-folder', yarnTestTmpDir], {
26+
cwd: testDir,
27+
shell: true,
28+
stdio: 'inherit',
29+
});
30+
}
31+
32+
fs.rmSync(yarnTestTmpDir, {recursive: true});

0 commit comments

Comments
 (0)