diff --git a/gulpfile.mjs b/gulpfile.mjs index 8f1075f45..611c78fee 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -35,7 +35,6 @@ import postcssNesting from "postcss-nesting"; import { preprocess } from "./external/builder/builder.mjs"; import rename from "gulp-rename"; import replace from "gulp-replace"; -import rimraf from "rimraf"; import stream from "stream"; import streamqueue from "streamqueue"; import TerserPlugin from "terser-webpack-plugin"; @@ -918,7 +917,7 @@ gulp.task("locale", function () { console.log(); console.log("### Building localization files"); - rimraf.sync(VIEWER_LOCALE_OUTPUT); + fs.rmSync(VIEWER_LOCALE_OUTPUT, { recursive: true, force: true }); fs.mkdirSync(VIEWER_LOCALE_OUTPUT, { recursive: true }); const subfolders = fs.readdirSync(L10N_DIR); @@ -1020,7 +1019,7 @@ function preprocessHTML(source, defines) { } function buildGeneric(defines, dir) { - rimraf.sync(dir); + fs.rmSync(dir, { recursive: true, force: true }); return merge([ createMainBundle(defines).pipe(gulp.dest(dir + "build")), @@ -1115,7 +1114,7 @@ gulp.task( ); function buildComponents(defines, dir) { - rimraf.sync(dir); + fs.rmSync(dir, { recursive: true, force: true }); const COMPONENTS_IMAGES = [ "web/images/annotation-*.svg", @@ -1201,7 +1200,7 @@ gulp.task( ); function buildMinified(defines, dir) { - rimraf.sync(dir); + fs.rmSync(dir, { recursive: true, force: true }); return merge([ createMainBundle(defines).pipe(gulp.dest(dir + "build")), @@ -1332,7 +1331,7 @@ gulp.task( }; // Clear out everything in the firefox extension build directory - rimraf.sync(MOZCENTRAL_DIR); + fs.rmSync(MOZCENTRAL_DIR, { recursive: true, force: true }); return merge([ createMainBundle(defines).pipe( @@ -1430,7 +1429,7 @@ gulp.task( ]; // Clear out everything in the chrome extension build directory - rimraf.sync(CHROME_BUILD_DIR); + fs.rmSync(CHROME_BUILD_DIR, { recursive: true, force: true }); const version = getVersionJSON().version; @@ -1503,17 +1502,16 @@ gulp.task("jsdoc", function (done) { const JSDOC_FILES = ["src/display/api.js"]; - rimraf(JSDOC_BUILD_DIR, function () { - fs.mkdirSync(JSDOC_BUILD_DIR, { recursive: true }); + fs.rmSync(JSDOC_BUILD_DIR, { recursive: true, force: true }); + fs.mkdirSync(JSDOC_BUILD_DIR, { recursive: true }); - const command = - '"node_modules/.bin/jsdoc" -d ' + - JSDOC_BUILD_DIR + - " " + - JSDOC_FILES.join(" "); + const command = + '"node_modules/.bin/jsdoc" -d ' + + JSDOC_BUILD_DIR + + " " + + JSDOC_FILES.join(" "); - exec(command, done); - }); + exec(command, done); }); gulp.task("types", function (done) { @@ -2013,7 +2011,7 @@ gulp.task( const defines = { ...DEFINES, GENERIC: true, TESTING: true }; const sandboxDir = BUILD_DIR + "dev-sandbox/"; - rimraf.sync(sandboxDir); + fs.rmSync(sandboxDir, { recursive: true, force: true }); return createSandboxBundle(defines, { disableVersionInfo: true, @@ -2059,7 +2057,8 @@ gulp.task("clean", function (done) { console.log(); console.log("### Cleaning up project builds"); - rimraf(BUILD_DIR, done); + fs.rmSync(BUILD_DIR, { recursive: true, force: true }); + done(); }); gulp.task("importl10n", async function () { @@ -2078,7 +2077,7 @@ function ghPagesPrepare() { console.log(); console.log("### Creating web site"); - rimraf.sync(GH_PAGES_DIR); + fs.rmSync(GH_PAGES_DIR, { recursive: true, force: true }); return merge([ gulp @@ -2192,13 +2191,20 @@ gulp.task( console.log(); console.log("### Cloning baseline distribution"); - rimraf.sync(DIST_DIR); + fs.rmSync(DIST_DIR, { recursive: true, force: true }); fs.mkdirSync(DIST_DIR, { recursive: true }); safeSpawnSync("git", ["clone", "--depth", "1", DIST_REPO_URL, DIST_DIR]); console.log(); console.log("### Overwriting all files"); - rimraf.sync(path.join(DIST_DIR, "*")); + + // Remove all files/folders, except for `.git` because it needs to be a + // valid Git repository for the Git commands in the `dist` target to work. + for (const entry of fs.readdirSync(DIST_DIR)) { + if (entry !== ".git") { + fs.rmSync(DIST_DIR + entry, { recursive: true, force: true }); + } + } return merge([ packageJson().pipe(gulp.dest(DIST_DIR)), @@ -2330,7 +2336,7 @@ gulp.task( console.log("### Creating mozcentral baseline environment"); // Create a mozcentral build. - rimraf.sync(BASELINE_DIR + BUILD_DIR); + fs.rmSync(BASELINE_DIR + BUILD_DIR, { recursive: true, force: true }); const workingDirectory = path.resolve(process.cwd(), BASELINE_DIR); safeSpawnSync("gulp", ["mozcentral"], { @@ -2340,7 +2346,7 @@ gulp.task( }); // Copy the mozcentral build to the mozcentral baseline directory. - rimraf.sync(MOZCENTRAL_BASELINE_DIR); + fs.rmSync(MOZCENTRAL_BASELINE_DIR, { recursive: true, force: true }); fs.mkdirSync(MOZCENTRAL_BASELINE_DIR, { recursive: true }); gulp @@ -2369,10 +2375,16 @@ gulp.task( // Create the diff between the current mozcentral build and the // baseline mozcentral build, which both exist at this point. - // The mozcentral baseline directory is a Git repository, so we - // remove all files and copy the current mozcentral build files - // into it to create the diff. - rimraf.sync(MOZCENTRAL_BASELINE_DIR + "*"); + // Remove all files/folders, except for `.git` because it needs to be a + // valid Git repository for the Git commands below to work. + for (const entry of fs.readdirSync(MOZCENTRAL_BASELINE_DIR)) { + if (entry !== ".git") { + fs.rmSync(MOZCENTRAL_BASELINE_DIR + entry, { + recursive: true, + force: true, + }); + } + } gulp .src([BUILD_DIR + "mozcentral/**/*"]) diff --git a/package-lock.json b/package-lock.json index 9a516c0bf..9c8f717d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,7 +53,6 @@ "postcss-nesting": "^12.1.4", "prettier": "^3.2.5", "puppeteer": "^22.8.1", - "rimraf": "^3.0.2", "streamqueue": "^1.1.2", "stylelint": "^16.5.0", "stylelint-prettier": "^5.0.0", diff --git a/package.json b/package.json index da538f6ae..8b5d32fb8 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "postcss-nesting": "^12.1.4", "prettier": "^3.2.5", "puppeteer": "^22.8.1", - "rimraf": "^3.0.2", "streamqueue": "^1.1.2", "stylelint": "^16.5.0", "stylelint-prettier": "^5.0.0",