-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate-core-hash.js
37 lines (28 loc) · 1.26 KB
/
update-core-hash.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs').promises;
const execa = require('execa');
(async () => {
try {
const coreFileName = 'shared/single-core/single-core.ts';
const jestCacheOfHashFileName = 'packages/jest-single/.core-version';
const jasmineCacheOfHashFileName = 'packages/jasmine-single/.core-version';
const {stdout} = await execa('git', ['hash-object', coreFileName]);
const latestCoreHash = stdout;
const jestCachedHash = await fs.readFile(jestCacheOfHashFileName, 'utf8');
const jasmineCachedHash = await fs.readFile(jasmineCacheOfHashFileName, 'utf8');
if (jestCachedHash === latestCoreHash && jasmineCachedHash === latestCoreHash) {
console.log('No changes in single-core');
return;
}
await fs.writeFile(jestCacheOfHashFileName, latestCoreHash);
await fs.writeFile(jasmineCacheOfHashFileName, latestCoreHash);
console.log(
'Updated single-core hash to help lerna know that it needs to bump versions'
);
// await execa('git', ['add', jestCacheOfHashFileName, jasmineCacheOfHashFileName]);
// const { stdout } = await execa('git', ['commit', '--amend', '--no-edit']);
console.log(stdout);
} catch (error) {
console.error(error);
}
})();