diff --git a/lib/chmod.ts b/lib/chmod.ts index a2016629..22c577ce 100644 --- a/lib/chmod.ts +++ b/lib/chmod.ts @@ -1,4 +1,4 @@ -import { chmod, stat } from 'fs-extra'; +import { chmod, stat } from 'fs/promises'; export async function plusx(file: string) { const s = await stat(file); diff --git a/lib/index.ts b/lib/index.ts index dd7beb7a..d7c27fe2 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,16 +1,8 @@ /* eslint-disable require-atomic-updates */ import assert from 'assert'; -import { - existsSync, - mkdirp, - readFile, - remove, - stat, - readFileSync, - writeFileSync, - copyFileSync, -} from 'fs-extra'; +import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'fs'; +import { mkdir, readFile, rm, stat } from 'fs/promises'; import minimist from 'minimist'; import { need, system } from '@yao-pkg/pkg-fetch'; import path from 'path'; @@ -574,7 +566,7 @@ export async function exec(argv2: string[]) { // ad-hoc sign the base binary temporarily to generate bytecode // due to the new mandatory signing requirement const signedBinaryPath = `${f.binaryPath}-signed`; - await remove(signedBinaryPath); + await rm(signedBinaryPath, { recursive: true, force: true }); copyFileSync(f.binaryPath, signedBinaryPath); try { signMachOExecutable(signedBinaryPath); @@ -665,14 +657,14 @@ export async function exec(argv2: string[]) { for (const target of targets) { if (target.output && existsSync(target.output)) { if ((await stat(target.output)).isFile()) { - await remove(target.output); + await rm(target.output, { recursive: true, force: true }); } else { throw wasReported('Refusing to overwrite non-file output', [ target.output, ]); } } else if (target.output) { - await mkdirp(path.dirname(target.output)); + await mkdir(path.dirname(target.output), { recursive: true }); } await producer({ diff --git a/lib/packer.ts b/lib/packer.ts index 9740e947..6230060b 100644 --- a/lib/packer.ts +++ b/lib/packer.ts @@ -1,7 +1,7 @@ /* eslint-disable complexity */ import assert from 'assert'; -import fs from 'fs-extra'; +import { readFileSync } from 'fs'; import path from 'path'; import { @@ -17,16 +17,17 @@ import { log, wasReported } from './log'; import { FileRecord, FileRecords, SymLinks } from './types'; const { version } = JSON.parse( - fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8'), + readFileSync(path.join(__dirname, '../package.json'), 'utf-8'), ); -const bootstrapText = fs - .readFileSync(require.resolve('../prelude/bootstrap.js'), 'utf8') - .replace('%VERSION%', version); +const bootstrapText = readFileSync( + require.resolve('../prelude/bootstrap.js'), + 'utf8', +).replace('%VERSION%', version); -const commonText = fs.readFileSync(require.resolve('./common'), 'utf8'); +const commonText = readFileSync(require.resolve('./common'), 'utf8'); -const diagnosticText = fs.readFileSync( +const diagnosticText = readFileSync( require.resolve('../prelude/diagnostic.js'), 'utf8', ); diff --git a/lib/producer.ts b/lib/producer.ts index 4f636ca3..771f91bd 100644 --- a/lib/producer.ts +++ b/lib/producer.ts @@ -2,7 +2,7 @@ import { createBrotliCompress, createGzip } from 'zlib'; import Multistream from 'multistream'; import assert from 'assert'; import { execFileSync } from 'child_process'; -import fs from 'fs-extra'; +import fs from 'fs'; import intoStream from 'into-stream'; import path from 'path'; import streamMeter from 'stream-meter'; @@ -291,7 +291,7 @@ function nativePrebuildInstall(target: Target, nodeFile: string) { fs.copyFileSync(nodeFile, nativeFile); // put the backed up file back - fs.moveSync(`${nodeFile}.bak`, nodeFile, { overwrite: true }); + fs.renameSync(`${nodeFile}.bak`, nodeFile); return nativeFile; } diff --git a/lib/walker.ts b/lib/walker.ts index a4a70300..1914fb01 100644 --- a/lib/walker.ts +++ b/lib/walker.ts @@ -1,7 +1,7 @@ /* eslint-disable require-atomic-updates */ import assert from 'assert'; -import fs from 'fs-extra'; +import fs from 'fs/promises'; import globby from 'globby'; import path from 'path'; import { builtinModules } from 'module'; diff --git a/package.json b/package.json index 021bcdc3..8f589c40 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "@babel/parser": "7.23.0", "@babel/types": "7.23.0", "@yao-pkg/pkg-fetch": "3.5.13", - "fs-extra": "^9.1.0", "globby": "^11.1.0", "into-stream": "^6.0.0", "minimist": "^1.2.6", @@ -41,7 +40,6 @@ "@babel/core": "7.23.0", "@release-it/conventional-changelog": "7.0.2", "@types/babel__generator": "7.6.5", - "@types/fs-extra": "9.0.13", "@types/minimist": "1.2.2", "@types/multistream": "4.1.0", "@types/node": "14.18.20", diff --git a/yarn.lock b/yarn.lock index 55d72ef6..77d0941e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -504,13 +504,6 @@ dependencies: "@babel/types" "^7.0.0" -"@types/fs-extra@9.0.13": - version "9.0.13" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45" - integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA== - dependencies: - "@types/node" "*" - "@types/http-cache-semantics@^4.0.2": version "4.0.4" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4"