Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/gulpfile.hygiene.js
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
const gulp = require('gulp');
7
const es = require('event-stream');
8
const path = require('path');
9
const task = require('./lib/task');
10
const { hygiene } = require('./hygiene');
11
12
/**
13
* @param {string} actualPath
14
*/
15
function checkPackageJSON(actualPath) {
16
const actual = require(path.join(__dirname, '..', actualPath));
17
const rootPackageJSON = require('../package.json');
18
const checkIncluded = (set1, set2) => {
19
for (const depName in set1) {
20
const depVersion = set1[depName];
21
const rootDepVersion = set2[depName];
22
if (!rootDepVersion) {
23
// missing in root is allowed
24
continue;
25
}
26
if (depVersion !== rootDepVersion) {
27
this.emit(
28
'error',
29
`The dependency ${depName} in '${actualPath}' (${depVersion}) is different than in the root package.json (${rootDepVersion})`
30
);
31
}
32
}
33
};
34
35
checkIncluded(actual.dependencies, rootPackageJSON.dependencies);
36
checkIncluded(actual.devDependencies, rootPackageJSON.devDependencies);
37
}
38
39
const checkPackageJSONTask = task.define('check-package-json', () => {
40
return gulp.src('package.json').pipe(
41
es.through(function () {
42
checkPackageJSON.call(this, 'remote/package.json');
43
checkPackageJSON.call(this, 'remote/web/package.json');
44
checkPackageJSON.call(this, 'build/package.json');
45
})
46
);
47
});
48
gulp.task(checkPackageJSONTask);
49
50
const hygieneTask = task.define('hygiene', task.series(checkPackageJSONTask, () => hygiene(undefined, false)));
51
gulp.task(hygieneTask);
52
53