Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the rimraf dependency in favor of the built-in Node.js fs.rmSync #18106

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 () {
Expand All @@ -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
Expand Down Expand Up @@ -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") {
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
fs.rmSync(DIST_DIR + entry, { recursive: true, force: true });
}
}

return merge([
packageJson().pipe(gulp.dest(DIST_DIR)),
Expand Down Expand Up @@ -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"], {
Expand All @@ -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
Expand Down Expand Up @@ -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/**/*"])
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down