diff --git a/lib/git.js b/lib/git.js index 5b729336..4505be2d 100644 --- a/lib/git.js +++ b/lib/git.js @@ -1,6 +1,6 @@ const cp = require('child_process'); +const fs = require('node:fs'); const path = require('path'); -const fs = require('fs-extra'); /** * @function Object() { [native code] } @@ -89,12 +89,11 @@ class Git { * @return {Promise} A promise. */ static async clone(repo, dir, branch, options) { - const exists = await fs.exists(dir); - if (exists) { + if (fs.existsSync(dir)) { return new Git(dir, options.git); } - await fs.mkdirp(path.dirname(path.resolve(dir))); + fs.mkdirSync(path.dirname(path.resolve(dir)), {recursive: true}); const args = [ 'clone', diff --git a/lib/index.js b/lib/index.js index 7b271753..ea7bede3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,8 +1,9 @@ +const fs = require('node:fs'); +const fsp = require('node:fs/promises'); const path = require('path'); const util = require('util'); const filenamify = require('filenamify'); const findCacheDir = require('find-cache-dir'); -const fs = require('fs-extra'); const tinyglobby = require('tinyglobby'); const Git = require('./git.js'); const copy = require('./util.js').copy; @@ -28,7 +29,7 @@ function getCacheDir(optPath) { * Clean the cache directory. */ exports.clean = function clean() { - fs.removeSync(getCacheDir()); + fs.rmSync(getCacheDir(), {recursive: true, force: true}); }; exports.defaults = { @@ -69,7 +70,7 @@ async function publishInternal(basePath, options) { options.remove = options.only; } - if (!(await fs.stat(basePath)).isDirectory()) { + if (!(await fsp.stat(basePath)).isDirectory()) { throw new Error('The "base" option must be an existing directory'); } @@ -133,12 +134,12 @@ async function publishInternal(basePath, options) { if (options.nojekyll) { log('Creating .nojekyll'); - await fs.createFile(path.join(git.cwd, '.nojekyll')); + await fsp.writeFile(path.join(git.cwd, '.nojekyll'), ''); } if (options.cname) { log('Creating CNAME for %s', options.cname); - await fs.writeFile(path.join(git.cwd, 'CNAME'), options.cname); + await fsp.writeFile(path.join(git.cwd, 'CNAME'), options.cname); } log('Copying files'); diff --git a/lib/util.js b/lib/util.js index ef6398f7..11233908 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,5 +1,5 @@ +const fsp = require('node:fs/promises'); const path = require('path'); -const fs = require('fs-extra'); const Git = require('./git.js'); /** @@ -49,8 +49,8 @@ exports.copy = async function (files, base, dest) { const src = path.resolve(base, file); const relative = path.relative(base, src); const target = path.join(dest, relative); - await fs.ensureDir(path.dirname(target)); - await fs.copy(src, target); + await fsp.mkdir(path.dirname(target), {recursive: true}); + await fsp.copyFile(src, target); } }; diff --git a/package-lock.json b/package-lock.json index 8ce6616c..db13975b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "email-addresses": "^5.0.0", "filenamify": "^4.3.0", "find-cache-dir": "^3.3.1", - "fs-extra": "^11.1.1", "tinyglobby": "^0.2.14" }, "bin": { @@ -435,6 +434,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1209,6 +1209,7 @@ "integrity": "sha512-TS9bTNIryDzStCpJN93aC5VRSW3uTx9sClUn4B87pwiCaJh220otoI0X8mJKr+VcPtniMdN8GKjlwgWGUv5ZKA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -1270,6 +1271,7 @@ "integrity": "sha512-lZBts941cyJyeaooiKxAtzoPHTN+GbQTJFAIdQbRhA4/8whaAraEh47Whw/ZFfrjNSnlAxqfm9i0XVAEkULjCw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "eslint-config-prettier": "build/bin/cli.js" }, @@ -1849,20 +1851,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/fs-extra": { - "version": "11.3.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.3.tgz", - "integrity": "sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==", - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -1998,10 +1986,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "license": "ISC" - }, "node_modules/has-bigints": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", @@ -2592,16 +2576,6 @@ "json5": "lib/cli.js" } }, - "node_modules/jsonfile": { - "version": "6.1.0", - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -3051,6 +3025,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -3081,6 +3056,7 @@ "integrity": "sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -3777,13 +3753,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/universalify": { - "version": "2.0.0", - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 3a372224..189a1ed2 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "email-addresses": "^5.0.0", "filenamify": "^4.3.0", "find-cache-dir": "^3.3.1", - "fs-extra": "^11.1.1", "tinyglobby": "^0.2.14" }, "devDependencies": { diff --git a/test/helper.js b/test/helper.js index 9964bafe..a0ce94ee 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,7 +1,7 @@ +const fs = require('node:fs'); const path = require('path'); const chai = require('chai'); const compare = require('dir-compare').compareSync; -const fs = require('fs-extra'); const tmp = require('tmp'); const Git = require('../lib/git.js'); @@ -48,7 +48,7 @@ async function setupRepo(fixtureName, options) { const userName = (options.user && options.user.name) || 'User Name'; const dir = await mkdtemp(); const fixturePath = path.join(fixtures, fixtureName, 'remote'); - await fs.copy(fixturePath, dir); + fs.cpSync(fixturePath, dir, {recursive: true}); const git = new Git(dir); await git.init();