diff --git a/package-lock.json b/package-lock.json index 1633816..a524389 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "MIT", "dependencies": { "electron-squirrel-startup": "^1.0.1", - "fs-extra": "^10.1.0", "react": "^17.0.1", "react-dom": "^17.0.1", "tslib": "^2.4.0", @@ -24,8 +23,7 @@ "@electron-forge/maker-squirrel": "^7.6.1", "@electron-forge/maker-zip": "^7.6.1", "@electron-forge/publisher-github": "^7.6.1", - "@types/fs-extra": "^9.0.13", - "@types/node": "^12.19.9", + "@types/node": "^20", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "electron": "34.2.0", @@ -3743,6 +3741,7 @@ "integrity": "sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==", "dev": true, "license": "MIT", + "optional": true, "dependencies": { "@types/node": "*" } @@ -3789,10 +3788,13 @@ "optional": true }, "node_modules/@types/node": { - "version": "12.20.50", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.50.tgz", - "integrity": "sha512-+9axpWx2b2JCVovr7Ilgt96uc6C1zBKOQMpGtRbWT9IoR/8ue32GGMfGA4woP8QyP2gBs6GQWEVM3tCybGCxDA==", - "license": "MIT" + "version": "20.17.19", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.19.tgz", + "integrity": "sha512-LEwC7o1ifqg/6r2gn9Dns0f1rhK+fPFDoMiceTJ6kWmVk6bgXBI/9IOWfVan4WiAavK9pIVWdX0/e3J+eEUh5A==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } }, "node_modules/@types/prop-types": { "version": "15.7.5", @@ -7475,15 +7477,6 @@ "node": ">= 4.0.0" } }, - "node_modules/electron/node_modules/@types/node": { - "version": "20.17.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.19.tgz", - "integrity": "sha512-LEwC7o1ifqg/6r2gn9Dns0f1rhK+fPFDoMiceTJ6kWmVk6bgXBI/9IOWfVan4WiAavK9pIVWdX0/e3J+eEUh5A==", - "license": "MIT", - "dependencies": { - "undici-types": "~6.19.2" - } - }, "node_modules/elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", @@ -8402,6 +8395,7 @@ "version": "10.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", @@ -10440,6 +10434,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, "license": "MIT", "dependencies": { "universalify": "^2.0.0" @@ -17347,6 +17342,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 10.0.0" diff --git a/package.json b/package.json index 9518d79..e143246 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ }, "dependencies": { "electron-squirrel-startup": "^1.0.1", - "fs-extra": "^10.1.0", "react": "^17.0.1", "react-dom": "^17.0.1", "tslib": "^2.4.0", @@ -36,8 +35,7 @@ "@electron-forge/maker-squirrel": "^7.6.1", "@electron-forge/maker-zip": "^7.6.1", "@electron-forge/publisher-github": "^7.6.1", - "@types/fs-extra": "^9.0.13", - "@types/node": "^12.19.9", + "@types/node": "^20", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "electron": "34.2.0", diff --git a/src/renderer/card-settings.tsx b/src/renderer/card-settings.tsx index 1b8ce11..2ac508c 100644 --- a/src/renderer/card-settings.tsx +++ b/src/renderer/card-settings.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import * as fs from "fs-extra"; +import * as fs from "fs"; import { getStatePath } from "./utils/get-state-path"; @@ -216,7 +216,11 @@ export class CardSettings extends React.Component< const statePath = await getStatePath(); if (fs.existsSync(statePath)) { - await fs.remove(statePath); + try { + await fs.promises.unlink(statePath); + } catch (error) { + console.error(`Failed to delete state file: ${error}`); + } } this.setState({ isStateReset: true }); diff --git a/src/renderer/emulator.tsx b/src/renderer/emulator.tsx index 31b36aa..7bcdff6 100644 --- a/src/renderer/emulator.tsx +++ b/src/renderer/emulator.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import * as fs from "fs-extra"; +import * as fs from "fs"; import * as path from "path"; import { ipcRenderer, shell } from "electron"; @@ -390,7 +390,9 @@ export class Emulator extends React.Component<{}, EmulatorState> { try { const newState = await emulator.save_state(); - await fs.outputFile(statePath, Buffer.from(newState)); + await fs.promises.writeFile(statePath, Buffer.from(newState), { + flush: true + }); } catch (error) { console.warn(`saveState: Could not save state`, error); } diff --git a/src/utils/disk-image-size.ts b/src/utils/disk-image-size.ts index 847da4f..133a6e6 100644 --- a/src/utils/disk-image-size.ts +++ b/src/utils/disk-image-size.ts @@ -1,4 +1,4 @@ -import * as fs from "fs-extra"; +import * as fs from "fs"; import { CONSTANTS } from "../constants"; @@ -9,7 +9,7 @@ import { CONSTANTS } from "../constants"; */ export async function getDiskImageSize(path: string) { try { - const stats = await fs.stat(path); + const stats = await fs.promises.stat(path); if (stats) { return stats.size; diff --git a/tools/parcel-build.js b/tools/parcel-build.js index 0e31289..597dc9f 100644 --- a/tools/parcel-build.js +++ b/tools/parcel-build.js @@ -2,7 +2,7 @@ const Bundler = require('parcel-bundler') const path = require('path') -const fs = require('fs-extra') +const fs = require('fs') async function copyLib() { const target = path.join(__dirname, '../dist/static') @@ -10,7 +10,7 @@ async function copyLib() { const index = path.join(target, 'index.html') // Copy in lib - await fs.copy(lib, target) + await fs.promises.cp(lib, target, { recursive: true }); // Patch so that fs.read is used const libv86path = path.join(target, 'libv86.js') @@ -66,8 +66,6 @@ async function compileParcel (options = {}) { await copyLib(); } - - module.exports = { compileParcel }