Merge pull request #276821 from mjbvz/dev/mjbvz/accurate-galliform

Try converting one of our gulpfiles to a module
This commit is contained in:
Matt Bierner 2025-11-11 15:03:51 -08:00 committed by GitHub
commit fdc7027b9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 31 deletions

View File

@ -2,19 +2,21 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import gulp from 'gulp';
import es from 'event-stream';
import path from 'path';
import fs from 'fs';
import task from './lib/task.js';
import { hygiene } from './hygiene.mjs';
const gulp = require('gulp');
const es = require('event-stream');
const path = require('path');
const task = require('./lib/task');
const { hygiene } = require('./hygiene');
const dirName = path.dirname(new URL(import.meta.url).pathname);
/**
* @param {string} actualPath
*/
function checkPackageJSON(actualPath) {
const actual = require(path.join(__dirname, '..', actualPath));
const rootPackageJSON = require('../package.json');
const actual = JSON.parse(fs.readFileSync(path.join(dirName, '..', actualPath), 'utf8'));
const rootPackageJSON = JSON.parse(fs.readFileSync(path.join(dirName, '..', 'package.json'), 'utf8'));
const checkIncluded = (set1, set2) => {
for (const depName in set1) {
const depVersion = set1[depName];

View File

@ -49,5 +49,5 @@ process.on('unhandledRejection', (reason, p) => {
});
// Load all the gulpfiles only if running tasks other than the editor tasks
require('glob').sync('gulpfile.*.js', { cwd: __dirname })
require('glob').sync('gulpfile.*.{js,mjs}', { cwd: __dirname })
.forEach(f => require(`./${f}`));

View File

@ -3,16 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
const filter = require('gulp-filter');
const es = require('event-stream');
const VinylFile = require('vinyl');
const vfs = require('vinyl-fs');
const path = require('path');
const fs = require('fs');
const pall = require('p-all');
const { all, copyrightFilter, unicodeFilter, indentationFilter, tsFormattingFilter, eslintFilter, stylelintFilter } = require('./filters');
import cp from 'child_process';
import es from 'event-stream';
import fs from 'fs';
import filter from 'gulp-filter';
import pall from 'p-all';
import path from 'path';
import VinylFile from 'vinyl';
import vfs from 'vinyl-fs';
import { all, copyrightFilter, eslintFilter, indentationFilter, stylelintFilter, tsFormattingFilter, unicodeFilter } from './filters.js';
import eslint from './gulp-eslint.js';
import formatter from './lib/formatter.js';
import gulpstylelint from './stylelint.js';
const copyrightHeaderLines = [
'/*---------------------------------------------------------------------------------------------',
@ -25,11 +27,8 @@ const copyrightHeaderLines = [
* @param {string[] | NodeJS.ReadWriteStream} some
* @param {boolean} runEslint
*/
function hygiene(some, runEslint = true) {
const eslint = require('./gulp-eslint');
const gulpstylelint = require('./stylelint');
const formatter = require('./lib/formatter');
export function hygiene(some, runEslint = true) {
console.log('Starting hygiene...');
let errorCount = 0;
const productJson = es.through(function (file) {
@ -226,13 +225,10 @@ function hygiene(some, runEslint = true) {
);
}
module.exports.hygiene = hygiene;
/**
* @param {string[]} paths
*/
function createGitIndexVinyls(paths) {
const cp = require('child_process');
const repositoryPath = process.cwd();
const fns = paths.map((relativePath) => () =>
@ -273,9 +269,7 @@ function createGitIndexVinyls(paths) {
}
// this allows us to run hygiene as a git pre-commit hook
if (require.main === module) {
const cp = require('child_process');
if (import.meta.filename === process.argv[1]) {
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
process.exit(1);

View File

@ -24,7 +24,8 @@
},
"include": [
"**/*.ts",
"**/*.js"
"**/*.js",
"**/*.mjs",
],
"exclude": [
"node_modules/**",

View File

@ -33,7 +33,7 @@
"watch-extensions": "node --max-old-space-size=8192 ./node_modules/gulp/bin/gulp.js watch-extensions watch-extension-media",
"watch-extensionsd": "deemon npm run watch-extensions",
"kill-watch-extensionsd": "deemon --kill npm run watch-extensions",
"precommit": "node build/hygiene.js",
"precommit": "node build/hygiene.mjs",
"gulp": "node --max-old-space-size=8192 ./node_modules/gulp/bin/gulp.js",
"electron": "node build/lib/electron",
"7z": "7z",