Skip to content

Commit

Permalink
Removed del package, replaced with native fs methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-mon1 committed Nov 19, 2024
1 parent b58ed5c commit 51f7d84
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 159 deletions.
18 changes: 11 additions & 7 deletions config/gulp/file-prep.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { src, series } = require("gulp");
const sharp = require("sharp");
const del = require("del");
const tap = require("gulp-tap");
const sizeOf = require("image-size");
const fs = require("fs");
Expand Down Expand Up @@ -205,12 +204,17 @@ function cleanFileName(origfilename) {
* removes files in content/images/_inbox directories
* keeps _inbox/__add image or static files to this folder__
*/
function cleanInbox() {
return del([
"content/uploads/_inbox/**",
"!content/uploads/_inbox",
"!content/uploads/_inbox/__add image or static files to this folder__",
]);
function cleanInbox(done) {
const inboxDir = `${filePaths.uploads}`;
const filesToDelete = fs
.readdirSync(inboxDir)
.filter((file) => file !== "__add image or static files to this folder__");

filesToDelete.forEach((file) => {
const filePath = path.join(inboxDir, file);
fs.unlinkSync(filePath);
});
done();
}

/**
Expand Down
20 changes: 12 additions & 8 deletions config/gulp/file-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { series } = require("gulp");
const sharp = require("sharp");
const fs = require("fs");
const path = require("path");
const del = require("del");

/**
* Set input and output directories for image processing
Expand Down Expand Up @@ -136,7 +135,7 @@ async function processImages() {
const imageToProcess = getImageDetails(image);
return Promise.all([
processImageOriginal(imageToProcess),
processImageVariants(imageToProcess)
processImageVariants(imageToProcess),
]);
});

Expand All @@ -156,12 +155,17 @@ async function processImages() {
*/
function removeProcessedImage() {
return new Promise((resolve, reject) => {
const imageDir = "content/uploads/_working-images/processed";

if (fs.existsSync(imageDir) && fs.readdirSync(imageDir).length > 0) {
return del([
"content/uploads/_working-images/to-process",
]).then(() => resolve()).catch((err) => reject(err));
if (
fs.existsSync(processedImagesDirectory) &&
fs.readdirSync(processedImagesDirectory).length > 0
) {
fs.rmdir(processImagesDirectory, { recursive: true }, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
} else {
resolve();
}
Expand Down
4 changes: 2 additions & 2 deletions config/gulp/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const replace = require("gulp-replace");
const sass = require("gulp-sass")(require("sass-embedded"));
const sourcemaps = require("gulp-sourcemaps");
const svgSprite = require("gulp-svg-sprite");
const del = require("del");
const rename = require("gulp-rename");
const pkg = require("../../node_modules/@uswds/uswds/package.json");

Expand Down Expand Up @@ -144,7 +143,8 @@ function renameSprite() {
}

function cleanSprite() {
return del.sync(`${IMG_DEST}/symbol`);
const spriteDir = `${IMG_DEST}/symbol`;
fs.rmdirSync(spriteDir, { recursive: true });
}

exports.init = series(
Expand Down
141 changes: 0 additions & 141 deletions 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 @@ -42,7 +42,6 @@
"@prantlf/jsonlint": "^14.0.3",
"@uswds/uswds": "^3.7.1",
"autoprefixer": "^10.4.16",
"del": "^8.0.0",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
"gulp": "^5.0.0",
Expand Down

0 comments on commit 51f7d84

Please sign in to comment.