vscode/build/gulpfile.hygiene.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-11-24 18:09:31 +00:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2020-09-22 12:37:04 +00:00
const gulp = require('gulp');
const es = require('event-stream');
const path = require('path');
const task = require('./lib/task');
2021-01-07 08:15:05 +00:00
const { hygiene } = require('./hygiene');
2016-02-18 15:02:16 +00:00
2022-02-28 22:32:12 +00:00
/**
* @param {string} actualPath
*/
2019-09-11 14:49:49 +00:00
function checkPackageJSON(actualPath) {
2020-09-22 12:37:04 +00:00
const actual = require(path.join(__dirname, '..', actualPath));
const rootPackageJSON = require('../package.json');
const checkIncluded = (set1, set2) => {
2022-06-08 15:49:21 +00:00
for (const depName in set1) {
2021-01-06 20:21:51 +00:00
const depVersion = set1[depName];
const rootDepVersion = set2[depName];
if (!rootDepVersion) {
// missing in root is allowed
continue;
}
if (depVersion !== rootDepVersion) {
this.emit(
'error',
`The dependency ${depName} in '${actualPath}' (${depVersion}) is different than in the root package.json (${rootDepVersion})`
);
}
}
};
checkIncluded(actual.dependencies, rootPackageJSON.dependencies);
checkIncluded(actual.devDependencies, rootPackageJSON.devDependencies);
2019-09-11 14:49:49 +00:00
}
2020-09-22 12:37:04 +00:00
const checkPackageJSONTask = task.define('check-package-json', () => {
return gulp.src('package.json').pipe(
2020-09-22 09:12:35 +00:00
es.through(function () {
2020-09-22 12:37:04 +00:00
checkPackageJSON.call(this, 'remote/package.json');
checkPackageJSON.call(this, 'remote/web/package.json');
checkPackageJSON.call(this, 'build/package.json');
2020-09-22 09:12:35 +00:00
})
);
2019-09-11 14:49:49 +00:00
});
gulp.task(checkPackageJSONTask);
2021-01-07 08:15:05 +00:00
const hygieneTask = task.define('hygiene', task.series(checkPackageJSONTask, () => hygiene(undefined, false)));
2021-01-06 20:21:51 +00:00
gulp.task(hygieneTask);