Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/common/computeNodeModulesCacheKey.js
3520 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
/*---------------------------------------------------------------------------------------------
7
* Copyright (c) Microsoft Corporation. All rights reserved.
8
* Licensed under the MIT License. See License.txt in the project root for license information.
9
*--------------------------------------------------------------------------------------------*/
10
const fs_1 = __importDefault(require("fs"));
11
const path_1 = __importDefault(require("path"));
12
const crypto_1 = __importDefault(require("crypto"));
13
const { dirs } = require('../../npm/dirs');
14
const ROOT = path_1.default.join(__dirname, '../../../');
15
const shasum = crypto_1.default.createHash('sha256');
16
shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, 'build/.cachesalt')));
17
shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, '.npmrc')));
18
shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, 'build', '.npmrc')));
19
shasum.update(fs_1.default.readFileSync(path_1.default.join(ROOT, 'remote', '.npmrc')));
20
// Add `package.json` and `package-lock.json` files
21
for (const dir of dirs) {
22
const packageJsonPath = path_1.default.join(ROOT, dir, 'package.json');
23
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath).toString());
24
const relevantPackageJsonSections = {
25
dependencies: packageJson.dependencies,
26
devDependencies: packageJson.devDependencies,
27
optionalDependencies: packageJson.optionalDependencies,
28
resolutions: packageJson.resolutions,
29
distro: packageJson.distro
30
};
31
shasum.update(JSON.stringify(relevantPackageJsonSections));
32
const packageLockPath = path_1.default.join(ROOT, dir, 'package-lock.json');
33
shasum.update(fs_1.default.readFileSync(packageLockPath));
34
}
35
// Add any other command line arguments
36
for (let i = 2; i < process.argv.length; i++) {
37
shasum.update(process.argv[i]);
38
}
39
process.stdout.write(shasum.digest('hex'));
40
//# sourceMappingURL=computeNodeModulesCacheKey.js.map
41