Skip to content

Commit 23ec0b4

Browse files
crisbetommalerba
authored andcommitted
build: install MDC canary dependencies through yarn (#23251)
Reworks the MDC canary script to use `yarn install` instead of going through `yarn add` in an attempt to avoid flakes on the CI. (cherry picked from commit c9e150c)
1 parent 8e38d30 commit 23ec0b4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

scripts/circleci/setup-mdc-canary.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const {join} = require('path');
2+
const {writeFileSync} = require('fs');
23
const {spawn, spawnSync} = require('child_process');
3-
const packageJson = require(join(__dirname, '../../package.json'));
4+
const packageJsonPath = join(__dirname, '../../package.json');
5+
const packageJson = require(packageJsonPath);
46
const versionsProcess = spawnSync('yarn', [
57
'info', 'material-components-web', 'dist-tags.canary', '--json'
68
], {shell: true});
@@ -13,18 +15,18 @@ try {
1315
throw e;
1416
}
1517

16-
const pattern = /^material-components-web$|^@material\//;
17-
const params = Object.keys(packageJson.devDependencies)
18-
.filter(dependency => pattern.test(dependency))
19-
.reduce((mdcDependencies, dependency) =>
20-
[...mdcDependencies, `${dependency}@${latestCanaryVersion}`], []);
18+
['devDependencies', 'dependencies'].forEach(field => {
19+
Object.keys(packageJson[field]).forEach(key => {
20+
if (/^material-components-web$|^@material\//.test(key)) {
21+
packageJson[field][key] = latestCanaryVersion;
22+
}
23+
});
24+
});
2125

22-
if (!params.length) {
23-
throw Error(`Could not find MDC dependencies in package.json`);
24-
}
26+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
2527

2628
console.log(`Updating all MDC dependencies to version ${latestCanaryVersion}`);
27-
const childProcess = spawn('yarn', ['add', ...params, '-D'], {shell: true});
29+
const childProcess = spawn('yarn', ['install', '--non-interactive'], {shell: true});
2830
childProcess.stdout.on('data', data => console.log(data + ''));
2931
childProcess.stderr.on('data', data => console.error(data + ''));
3032
childProcess.on('exit', code => process.exit(code));

0 commit comments

Comments
 (0)