vscode/build/gulpfile.hygiene.js

49 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-11-24 19:09:31 +01: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 14:37:04 +02:00
const gulp = require('gulp');
const es = require('event-stream');
const path = require('path');
const task = require('./lib/task');
2021-01-07 09:15:05 +01:00
const { hygiene } = require('./hygiene');
2016-02-18 16:02:16 +01:00
2019-09-11 16:49:49 +02:00
function checkPackageJSON(actualPath) {
2020-09-22 14:37:04 +02:00
const actual = require(path.join(__dirname, '..', actualPath));
const rootPackageJSON = require('../package.json');
const checkIncluded = (set1, set2) => {
for (let depName in set1) {
2021-01-06 21:21:51 +01: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 16:49:49 +02:00
}
2020-09-22 14:37:04 +02:00
const checkPackageJSONTask = task.define('check-package-json', () => {
return gulp.src('package.json').pipe(
2020-09-22 11:12:35 +02:00
es.through(function () {
2020-09-22 14:37:04 +02:00
checkPackageJSON.call(this, 'remote/package.json');
checkPackageJSON.call(this, 'remote/web/package.json');
checkPackageJSON.call(this, 'build/package.json');
2020-09-22 11:12:35 +02:00
})
);
2019-09-11 16:49:49 +02:00
});
gulp.task(checkPackageJSONTask);
2021-01-07 09:15:05 +01:00
const hygieneTask = task.define('hygiene', task.series(checkPackageJSONTask, () => hygiene(undefined, false)));
2021-01-06 21:21:51 +01:00
gulp.task(hygieneTask);