From 51f7d844fbcfc761bac26ba9ec4e1f2e00a50463 Mon Sep 17 00:00:00 2001 From: Nick Lyons Date: Tue, 19 Nov 2024 15:29:51 -0500 Subject: [PATCH] Removed del package, replaced with native fs methods --- config/gulp/file-prep.js | 18 +++-- config/gulp/file-process.js | 20 +++-- config/gulp/styles.js | 4 +- package-lock.json | 141 ------------------------------------ package.json | 1 - 5 files changed, 25 insertions(+), 159 deletions(-) diff --git a/config/gulp/file-prep.js b/config/gulp/file-prep.js index b863ed225a..3886e5165b 100644 --- a/config/gulp/file-prep.js +++ b/config/gulp/file-prep.js @@ -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"); @@ -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(); } /** diff --git a/config/gulp/file-process.js b/config/gulp/file-process.js index 3be32dfc25..687224b7c2 100644 --- a/config/gulp/file-process.js +++ b/config/gulp/file-process.js @@ -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 @@ -136,7 +135,7 @@ async function processImages() { const imageToProcess = getImageDetails(image); return Promise.all([ processImageOriginal(imageToProcess), - processImageVariants(imageToProcess) + processImageVariants(imageToProcess), ]); }); @@ -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(); } diff --git a/config/gulp/styles.js b/config/gulp/styles.js index 889171e3b2..4e0c39e5f1 100644 --- a/config/gulp/styles.js +++ b/config/gulp/styles.js @@ -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"); @@ -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( diff --git a/package-lock.json b/package-lock.json index a3e34cb0a1..1f27f73923 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,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", @@ -2124,18 +2123,6 @@ "node": ">= 10" } }, - "node_modules/@sindresorhus/merge-streams": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", - "integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@smithy/abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-3.1.1.tgz", @@ -4589,98 +4576,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/del": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/del/-/del-8.0.0.tgz", - "integrity": "sha512-R6ep6JJ+eOBZsBr9esiNN1gxFbZE4Q2cULkUSFumGYecAiS6qodDvcPx/sFuWHMNul7DWmrtoEOpYSm7o6tbSA==", - "license": "MIT", - "dependencies": { - "globby": "^14.0.2", - "is-glob": "^4.0.3", - "is-path-cwd": "^3.0.0", - "is-path-inside": "^4.0.0", - "p-map": "^7.0.2", - "slash": "^5.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/del/node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/del/node_modules/globby": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/globby/-/globby-14.0.2.tgz", - "integrity": "sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==", - "license": "MIT", - "dependencies": { - "@sindresorhus/merge-streams": "^2.1.0", - "fast-glob": "^3.3.2", - "ignore": "^5.2.4", - "path-type": "^5.0.0", - "slash": "^5.1.0", - "unicorn-magic": "^0.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/del/node_modules/is-path-inside": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", - "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/del/node_modules/path-type": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-5.0.0.tgz", - "integrity": "sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/del/node_modules/slash": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", - "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", - "license": "MIT", - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -7224,18 +7119,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-path-cwd": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-3.0.0.tgz", - "integrity": "sha512-kyiNFFLU0Ampr6SDZitD/DwUo4Zs1nSdnygUBqsu3LooL00Qvb5j+UnvApUn/TTj1J3OuE6BTdQ5rudKmU2ZaA==", - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -8741,18 +8624,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-map": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.2.tgz", - "integrity": "sha512-z4cYYMMdKHzw4O5UkWJImbZynVIo0lSGTXc7bzB1e/rrDqkgGUNysK/o4bTr+0+xKvvLoTyGqYC4Fgljy9qe1Q==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -11839,18 +11710,6 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" }, - "node_modules/unicorn-magic": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", - "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/update-browserslist-db": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", diff --git a/package.json b/package.json index df84d63ed3..e22b49607d 100644 --- a/package.json +++ b/package.json @@ -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",