build: remove fs-extra devdep (#42533)

* build: remove fs-extra dependency from script/gen-filenames.ts

* build: remove fs-extra dependency from script/spec-runner.js

* build: remove fs-extra dependency from script/gn-asar.js

* build: remove fs-extra dependency from spec/api-autoupdater-darwin-spec.ts

* build: remove fs-extra dependency from spec/api-safe-storage-spec.ts

* build: remove fs-extra dependency from spec/lib/codesign-helpers.ts

* build: remove fs-extra dependency from spec/api-app-spec.ts

* build: remove fs-extra dependency from spec/esm-spec.ts

* build: remove fs-extra dependency from spec/lib/fs-helpers.ts

* build: remove fs-extra dependency from spec/lib/api-shell-spec.ts

* build: remove fs-extra dependency from spec/api-context-bridge-spec.ts

* build: remove fs-extra dependency from spec/asar-integrity-spec.ts

* build: remove fs-extra dependency from spec/node-spec.ts

* build: remove fs-extra devdiv

* fixup! build: remove fs-extra dependency from spec/api-context-bridge-spec.ts

* fix: use force: true when removing directories

* chore: reduce diffs to main
This commit is contained in:
Charles Kerr 2024-06-19 09:10:16 -05:00 committed by GitHub
parent 8e8ea3ee8b
commit dad6e130f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 55 additions and 80 deletions

View file

@ -19,7 +19,6 @@
"@types/chai-as-promised": "^7.1.3", "@types/chai-as-promised": "^7.1.3",
"@types/dirty-chai": "^2.0.2", "@types/dirty-chai": "^2.0.2",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/fs-extra": "^9.0.1",
"@types/minimist": "^1.2.0", "@types/minimist": "^1.2.0",
"@types/mocha": "^7.0.2", "@types/mocha": "^7.0.2",
"@types/node": "^20.9.0", "@types/node": "^20.9.0",
@ -50,7 +49,6 @@
"events": "^3.2.0", "events": "^3.2.0",
"express": "^4.19.2", "express": "^4.19.2",
"folder-hash": "^2.1.1", "folder-hash": "^2.1.1",
"fs-extra": "^9.0.1",
"got": "^11.8.5", "got": "^11.8.5",
"husky": "^8.0.1", "husky": "^8.0.1",
"lint": "^1.1.2", "lint": "^1.1.2",

View file

@ -1,5 +1,5 @@
import * as cp from 'node:child_process'; import * as cp from 'node:child_process';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as os from 'node:os'; import * as os from 'node:os';
import * as path from 'node:path'; import * as path from 'node:path';
@ -48,7 +48,7 @@ const main = async () => {
]; ];
const webpackTargetsWithDeps = await Promise.all(webpackTargets.map(async webpackTarget => { const webpackTargetsWithDeps = await Promise.all(webpackTargets.map(async webpackTarget => {
const tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-filenames-')); const tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-filenames-'));
const child = cp.spawn('node', [ const child = cp.spawn('node', [
'./node_modules/webpack-cli/bin/cli.js', './node_modules/webpack-cli/bin/cli.js',
'--config', `./build/webpack/${webpackTarget.config}`, '--config', `./build/webpack/${webpackTarget.config}`,
@ -89,7 +89,7 @@ const main = async () => {
// Make the generated list easier to read // Make the generated list easier to read
.sort() .sort()
}; };
await fs.remove(tmpDir); await fs.promises.rm(tmpDir, { force: true, recursive: true });
return webpackTargetWithDeps; return webpackTargetWithDeps;
})); }));

View file

@ -1,6 +1,6 @@
const asar = require('@electron/asar'); const asar = require('@electron/asar');
const assert = require('node:assert'); const assert = require('node:assert');
const fs = require('fs-extra'); const fs = require('node:fs');
const os = require('node:os'); const os = require('node:os');
const path = require('node:path'); const path = require('node:path');
@ -41,12 +41,12 @@ try {
// Copy all files to a tmp dir to avoid including scrap files in the ASAR // Copy all files to a tmp dir to avoid including scrap files in the ASAR
for (const file of files) { for (const file of files) {
const newLocation = path.resolve(tmpPath, path.relative(base[0], file)); const newLocation = path.resolve(tmpPath, path.relative(base[0], file));
fs.mkdirsSync(path.dirname(newLocation)); fs.mkdirSync(path.dirname(newLocation), { recursive: true });
fs.writeFileSync(newLocation, fs.readFileSync(file)); fs.writeFileSync(newLocation, fs.readFileSync(file));
} }
} catch (err) { } catch (err) {
console.error('Unexpected error while generating ASAR', err); console.error('Unexpected error while generating ASAR', err);
fs.remove(tmpPath) fs.promises.rm(tmpPath, { force: true, recursive: true })
.then(() => process.exit(1)) .then(() => process.exit(1))
.catch(() => process.exit(1)); .catch(() => process.exit(1));
return; return;
@ -59,5 +59,5 @@ asar.createPackageWithOptions(tmpPath, out[0], {})
console.error('Unexpected error while generating ASAR', err); console.error('Unexpected error while generating ASAR', err);
process.exit(1); process.exit(1);
}; };
fs.remove(tmpPath).then(exit).catch(exit); fs.promises.rm(tmpPath, { force: true, recursive: true }).then(exit).catch(exit);
}).then(() => fs.remove(tmpPath)); }).then(() => fs.promises.rm(tmpPath, { force: true, recursive: true }));

View file

@ -3,7 +3,7 @@
const { ElectronVersions, Installer } = require('@electron/fiddle-core'); const { ElectronVersions, Installer } = require('@electron/fiddle-core');
const childProcess = require('node:child_process'); const childProcess = require('node:child_process');
const crypto = require('node:crypto'); const crypto = require('node:crypto');
const fs = require('fs-extra'); const fs = require('node:fs');
const { hashElement } = require('folder-hash'); const { hashElement } = require('folder-hash');
const os = require('node:os'); const os = require('node:os');
const path = require('node:path'); const path = require('node:path');
@ -216,7 +216,7 @@ async function installSpecModules (dir) {
env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`);
} }
if (fs.existsSync(path.resolve(dir, 'node_modules'))) { if (fs.existsSync(path.resolve(dir, 'node_modules'))) {
await fs.remove(path.resolve(dir, 'node_modules')); await fs.promises.rm(path.resolve(dir, 'node_modules'), { force: true, recursive: true });
} }
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], { const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
env, env,

View file

@ -3,7 +3,7 @@ import * as cp from 'node:child_process';
import * as https from 'node:https'; import * as https from 'node:https';
import * as http from 'node:http'; import * as http from 'node:http';
import * as net from 'node:net'; import * as net from 'node:net';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import { promisify } from 'node:util'; import { promisify } from 'node:util';
import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main'; import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main';
@ -1118,7 +1118,7 @@ describe('app module', () => {
describe('sessionData', () => { describe('sessionData', () => {
const appPath = path.join(__dirname, 'fixtures', 'apps', 'set-path'); const appPath = path.join(__dirname, 'fixtures', 'apps', 'set-path');
const appName = fs.readJsonSync(path.join(appPath, 'package.json')).name; const appName = JSON.parse(fs.readFileSync(path.join(appPath, 'package.json'), 'utf8')).name;
const userDataPath = path.join(app.getPath('appData'), appName); const userDataPath = path.join(app.getPath('appData'), appName);
const tempBrowserDataPath = path.join(app.getPath('temp'), appName); const tempBrowserDataPath = path.join(app.getPath('temp'), appName);
@ -1139,8 +1139,8 @@ describe('app module', () => {
}; };
beforeEach(() => { beforeEach(() => {
fs.removeSync(userDataPath); fs.rmSync(userDataPath, { force: true, recursive: true });
fs.removeSync(tempBrowserDataPath); fs.rmSync(tempBrowserDataPath, { force: true, recursive: true });
}); });
it('writes to userData by default', () => { it('writes to userData by default', () => {

View file

@ -2,7 +2,7 @@ import { expect } from 'chai';
import * as cp from 'node:child_process'; import * as cp from 'node:child_process';
import * as http from 'node:http'; import * as http from 'node:http';
import * as express from 'express'; import * as express from 'express';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import * as psList from 'ps-list'; import * as psList from 'ps-list';
import { AddressInfo } from 'node:net'; import { AddressInfo } from 'node:net';
@ -68,14 +68,14 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
await withTempDirectory(async (dir) => { await withTempDirectory(async (dir) => {
const secondAppPath = await copyMacOSFixtureApp(dir, fixture); const secondAppPath = await copyMacOSFixtureApp(dir, fixture);
const appPJPath = path.resolve(secondAppPath, 'Contents', 'Resources', 'app', 'package.json'); const appPJPath = path.resolve(secondAppPath, 'Contents', 'Resources', 'app', 'package.json');
await fs.writeFile( await fs.promises.writeFile(
appPJPath, appPJPath,
(await fs.readFile(appPJPath, 'utf8')).replace('1.0.0', version) (await fs.promises.readFile(appPJPath, 'utf8')).replace('1.0.0', version)
); );
const infoPath = path.resolve(secondAppPath, 'Contents', 'Info.plist'); const infoPath = path.resolve(secondAppPath, 'Contents', 'Info.plist');
await fs.writeFile( await fs.promises.writeFile(
infoPath, infoPath,
(await fs.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, `$1${version}`) (await fs.promises.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, `$1${version}`)
); );
await mutateAppPreSign?.mutate(secondAppPath); await mutateAppPreSign?.mutate(secondAppPath);
await signApp(secondAppPath, identity); await signApp(secondAppPath, identity);
@ -221,9 +221,9 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
const appPath = await copyMacOSFixtureApp(dir, opts.startFixture); const appPath = await copyMacOSFixtureApp(dir, opts.startFixture);
await opts.mutateAppPreSign?.mutate(appPath); await opts.mutateAppPreSign?.mutate(appPath);
const infoPath = path.resolve(appPath, 'Contents', 'Info.plist'); const infoPath = path.resolve(appPath, 'Contents', 'Info.plist');
await fs.writeFile( await fs.promises.writeFile(
infoPath, infoPath,
(await fs.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, '$11.0.0') (await fs.promises.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, '$11.0.0')
); );
await signApp(appPath, identity); await signApp(appPath, identity);
@ -378,9 +378,9 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
mutationKey: 'prevent-downgrades', mutationKey: 'prevent-downgrades',
mutate: async (appPath) => { mutate: async (appPath) => {
const infoPath = path.resolve(appPath, 'Contents', 'Info.plist'); const infoPath = path.resolve(appPath, 'Contents', 'Info.plist');
await fs.writeFile( await fs.promises.writeFile(
infoPath, infoPath,
(await fs.readFile(infoPath, 'utf8')).replace('<key>NSSupportsAutomaticGraphicsSwitching</key>', '<key>ElectronSquirrelPreventDowngrades</key><true/><key>NSSupportsAutomaticGraphicsSwitching</key>') (await fs.promises.readFile(infoPath, 'utf8')).replace('<key>NSSupportsAutomaticGraphicsSwitching</key>', '<key>ElectronSquirrelPreventDowngrades</key><true/><key>NSSupportsAutomaticGraphicsSwitching</key>')
); );
} }
} }
@ -418,9 +418,9 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
mutationKey: 'prevent-downgrades', mutationKey: 'prevent-downgrades',
mutate: async (appPath) => { mutate: async (appPath) => {
const infoPath = path.resolve(appPath, 'Contents', 'Info.plist'); const infoPath = path.resolve(appPath, 'Contents', 'Info.plist');
await fs.writeFile( await fs.promises.writeFile(
infoPath, infoPath,
(await fs.readFile(infoPath, 'utf8')).replace('<key>NSSupportsAutomaticGraphicsSwitching</key>', '<key>ElectronSquirrelPreventDowngrades</key><true/><key>NSSupportsAutomaticGraphicsSwitching</key>') (await fs.promises.readFile(infoPath, 'utf8')).replace('<key>NSSupportsAutomaticGraphicsSwitching</key>', '<key>ElectronSquirrelPreventDowngrades</key><true/><key>NSSupportsAutomaticGraphicsSwitching</key>')
); );
} }
} }
@ -558,7 +558,7 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
await shipItFlipFlopPromise; await shipItFlipFlopPromise;
expect(requests).to.have.lengthOf(2, 'should not have relaunched the updated app'); expect(requests).to.have.lengthOf(2, 'should not have relaunched the updated app');
expect(JSON.parse(await fs.readFile(path.resolve(appPath, 'Contents/Resources/app/package.json'), 'utf8')).version).to.equal('1.0.0', 'should still be the old version on disk'); expect(JSON.parse(await fs.promises.readFile(path.resolve(appPath, 'Contents/Resources/app/package.json'), 'utf8')).version).to.equal('1.0.0', 'should still be the old version on disk');
retainerHandle.kill('SIGINT'); retainerHandle.kill('SIGINT');
}); });
@ -631,7 +631,7 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
mutationKey: 'add-resource', mutationKey: 'add-resource',
mutate: async (appPath) => { mutate: async (appPath) => {
const resourcesPath = path.resolve(appPath, 'Contents', 'Resources', 'app', 'injected.txt'); const resourcesPath = path.resolve(appPath, 'Contents', 'Resources', 'app', 'injected.txt');
await fs.writeFile(resourcesPath, 'demo'); await fs.promises.writeFile(resourcesPath, 'demo');
} }
} }
}, async (appPath, updateZipPath) => { }, async (appPath, updateZipPath) => {
@ -669,8 +669,8 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
mutationKey: 'modify-shipit', mutationKey: 'modify-shipit',
mutate: async (appPath) => { mutate: async (appPath) => {
const shipItPath = path.resolve(appPath, 'Contents', 'Frameworks', 'Squirrel.framework', 'Resources', 'ShipIt'); const shipItPath = path.resolve(appPath, 'Contents', 'Frameworks', 'Squirrel.framework', 'Resources', 'ShipIt');
await fs.remove(shipItPath); await fs.promises.rm(shipItPath, { force: true, recursive: true });
await fs.symlink('/tmp/ShipIt', shipItPath, 'file'); await fs.promises.symlink('/tmp/ShipIt', shipItPath, 'file');
} }
} }
}, async (appPath, updateZipPath) => { }, async (appPath, updateZipPath) => {
@ -708,7 +708,7 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
mutationKey: 'modify-eframework', mutationKey: 'modify-eframework',
mutate: async (appPath) => { mutate: async (appPath) => {
const shipItPath = path.resolve(appPath, 'Contents', 'Frameworks', 'Electron Framework.framework', 'Electron Framework'); const shipItPath = path.resolve(appPath, 'Contents', 'Frameworks', 'Electron Framework.framework', 'Electron Framework');
await fs.appendFile(shipItPath, Buffer.from('123')); await fs.promises.appendFile(shipItPath, Buffer.from('123'));
} }
} }
}, async (appPath, updateZipPath) => { }, async (appPath, updateZipPath) => {

View file

@ -1,7 +1,7 @@
import { BrowserWindow, ipcMain } from 'electron/main'; import { BrowserWindow, ipcMain } from 'electron/main';
import { contextBridge } from 'electron/renderer'; import { contextBridge } from 'electron/renderer';
import { expect } from 'chai'; import { expect } from 'chai';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as http from 'node:http'; import * as http from 'node:http';
import * as os from 'node:os'; import * as os from 'node:os';
import * as path from 'node:path'; import * as path from 'node:path';
@ -34,7 +34,7 @@ describe('contextBridge', () => {
afterEach(async () => { afterEach(async () => {
await closeWindow(w); await closeWindow(w);
if (dir) await fs.remove(dir); if (dir) await fs.promises.rm(dir, { force: true, recursive: true });
}); });
it('should not be accessible when contextIsolation is disabled', async () => { it('should not be accessible when contextIsolation is disabled', async () => {
@ -85,9 +85,9 @@ describe('contextBridge', () => {
});`} });`}
(${bindingCreator.toString()})();`; (${bindingCreator.toString()})();`;
const tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-spec-preload-')); const tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-spec-preload-'));
dir = tmpDir; dir = tmpDir;
await fs.writeFile(path.resolve(tmpDir, 'preload.js'), worldId === 0 ? preloadContentForMainWorld : preloadContentForIsolatedWorld); await fs.promises.writeFile(path.resolve(tmpDir, 'preload.js'), worldId === 0 ? preloadContentForMainWorld : preloadContentForIsolatedWorld);
w = new BrowserWindow({ w = new BrowserWindow({
show: false, show: false,
webPreferences: { webPreferences: {

View file

@ -3,7 +3,7 @@ import * as path from 'node:path';
import { safeStorage } from 'electron/main'; import { safeStorage } from 'electron/main';
import { expect } from 'chai'; import { expect } from 'chai';
import { ifdescribe } from './lib/spec-helpers'; import { ifdescribe } from './lib/spec-helpers';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import { once } from 'node:events'; import { once } from 'node:events';
describe('safeStorage module', () => { describe('safeStorage module', () => {
@ -33,8 +33,8 @@ describe('safeStorage module', () => {
after(async () => { after(async () => {
const pathToEncryptedString = path.resolve(__dirname, 'fixtures', 'api', 'safe-storage', 'encrypted.txt'); const pathToEncryptedString = path.resolve(__dirname, 'fixtures', 'api', 'safe-storage', 'encrypted.txt');
if (await fs.pathExists(pathToEncryptedString)) { if (fs.existsSync(pathToEncryptedString)) {
await fs.remove(pathToEncryptedString); await fs.promises.rm(pathToEncryptedString, { force: true, recursive: true });
} }
}); });

View file

@ -3,7 +3,7 @@ import { shell } from 'electron/common';
import { closeAllWindows } from './lib/window-helpers'; import { closeAllWindows } from './lib/window-helpers';
import { ifdescribe, ifit, listen } from './lib/spec-helpers'; import { ifdescribe, ifit, listen } from './lib/spec-helpers';
import * as http from 'node:http'; import * as http from 'node:http';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as os from 'node:os'; import * as os from 'node:os';
import * as path from 'node:path'; import * as path from 'node:path';
import { expect } from 'chai'; import { expect } from 'chai';
@ -79,9 +79,9 @@ describe('shell module', () => {
afterEach(closeAllWindows); afterEach(closeAllWindows);
it('moves an item to the trash', async () => { it('moves an item to the trash', async () => {
const dir = await fs.mkdtemp(path.resolve(app.getPath('temp'), 'electron-shell-spec-')); const dir = await fs.promises.mkdtemp(path.resolve(app.getPath('temp'), 'electron-shell-spec-'));
const filename = path.join(dir, 'temp-to-be-deleted'); const filename = path.join(dir, 'temp-to-be-deleted');
await fs.writeFile(filename, 'dummy-contents'); await fs.promises.writeFile(filename, 'dummy-contents');
await shell.trashItem(filename); await shell.trashItem(filename);
expect(fs.existsSync(filename)).to.be.false(); expect(fs.existsSync(filename)).to.be.false();
}); });

View file

@ -2,7 +2,7 @@ import { expect } from 'chai';
import * as cp from 'node:child_process'; import * as cp from 'node:child_process';
import * as nodeCrypto from 'node:crypto'; import * as nodeCrypto from 'node:crypto';
import * as originalFs from 'node:original-fs'; import * as originalFs from 'node:original-fs';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as os from 'node:os'; import * as os from 'node:os';
import * as path from 'node:path'; import * as path from 'node:path';
import { ifdescribe } from './lib/spec-helpers'; import { ifdescribe } from './lib/spec-helpers';
@ -82,7 +82,7 @@ describe('fuses', function () {
}; };
beforeEach(async () => { beforeEach(async () => {
tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-asar-integrity-spec-')); tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-asar-integrity-spec-'));
appPath = await copyApp(tmpDir); appPath = await copyApp(tmpDir);
}); });

View file

@ -1,7 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as cp from 'node:child_process'; import * as cp from 'node:child_process';
import { BrowserWindow } from 'electron'; import { BrowserWindow } from 'electron';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as os from 'node:os'; import * as os from 'node:os';
import * as path from 'node:path'; import * as path from 'node:path';
import { pathToFileURL } from 'node:url'; import { pathToFileURL } from 'node:url';
@ -72,15 +72,15 @@ describe('esm', () => {
if (w) w.close(); if (w) w.close();
w = null; w = null;
while (tempDirs.length) { while (tempDirs.length) {
await fs.remove(tempDirs.pop()!); await fs.promises.rm(tempDirs.pop()!, { force: true, recursive: true });
} }
}); });
async function loadWindowWithPreload (preload: string, webPreferences: Electron.WebPreferences) { async function loadWindowWithPreload (preload: string, webPreferences: Electron.WebPreferences) {
const tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'e-spec-preload-')); const tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'e-spec-preload-'));
tempDirs.push(tmpDir); tempDirs.push(tmpDir);
const preloadPath = path.resolve(tmpDir, 'preload.mjs'); const preloadPath = path.resolve(tmpDir, 'preload.mjs');
await fs.writeFile(preloadPath, preload); await fs.promises.writeFile(preloadPath, preload);
w = new BrowserWindow({ w = new BrowserWindow({
show: false, show: false,

View file

@ -1,5 +1,5 @@
import * as cp from 'node:child_process'; import * as cp from 'node:child_process';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import { expect } from 'chai'; import { expect } from 'chai';
@ -37,13 +37,13 @@ export async function copyMacOSFixtureApp (newDir: string, fixture: string | nul
cp.spawnSync('cp', ['-R', appBundlePath, path.dirname(newPath)]); cp.spawnSync('cp', ['-R', appBundlePath, path.dirname(newPath)]);
if (fixture) { if (fixture) {
const appDir = path.resolve(newPath, 'Contents/Resources/app'); const appDir = path.resolve(newPath, 'Contents/Resources/app');
await fs.mkdirp(appDir); await fs.promises.mkdir(appDir, { recursive: true });
await fs.copy(path.resolve(fixturesPath, 'auto-update', fixture), appDir); await fs.promises.cp(path.resolve(fixturesPath, 'auto-update', fixture), appDir, { recursive: true });
} }
const plistPath = path.resolve(newPath, 'Contents', 'Info.plist'); const plistPath = path.resolve(newPath, 'Contents', 'Info.plist');
await fs.writeFile( await fs.promises.writeFile(
plistPath, plistPath,
(await fs.readFile(plistPath, 'utf8')).replace('<key>BuildMachineOSBuild</key>', `<key>NSAppTransportSecurity</key> (await fs.promises.readFile(plistPath, 'utf8')).replace('<key>BuildMachineOSBuild</key>', `<key>NSAppTransportSecurity</key>
<dict> <dict>
<key>NSAllowsArbitraryLoads</key> <key>NSAllowsArbitraryLoads</key>
<true/> <true/>

View file

@ -1,6 +1,5 @@
import * as cp from 'node:child_process'; import * as cp from 'node:child_process';
import * as fs from 'original-fs'; import * as fs from 'original-fs';
import * as fsExtra from 'fs-extra';
import * as os from 'node:os'; import * as os from 'node:os';
import * as path from 'node:path'; import * as path from 'node:path';
@ -20,7 +19,7 @@ export async function copyApp (targetDir: string): Promise<string> {
const filesToCopy = (fs.readFileSync(zipManifestPath, 'utf-8')).split('\n').filter(f => f !== 'LICENSE' && f !== 'LICENSES.chromium.html' && f !== 'version' && f.trim()); const filesToCopy = (fs.readFileSync(zipManifestPath, 'utf-8')).split('\n').filter(f => f !== 'LICENSE' && f !== 'LICENSES.chromium.html' && f !== 'version' && f.trim());
await Promise.all( await Promise.all(
filesToCopy.map(async rel => { filesToCopy.map(async rel => {
await fsExtra.mkdirp(path.dirname(path.resolve(targetDir, rel))); await fs.promises.mkdir(path.dirname(path.resolve(targetDir, rel)), { recursive: true });
fs.copyFileSync(path.resolve(baseDir, rel), path.resolve(targetDir, rel)); fs.copyFileSync(path.resolve(baseDir, rel), path.resolve(targetDir, rel));
}) })
); );
@ -29,7 +28,7 @@ export async function copyApp (targetDir: string): Promise<string> {
} }
export async function withTempDirectory (fn: (dir: string) => Promise<void>, autoCleanUp = true) { export async function withTempDirectory (fn: (dir: string) => Promise<void>, autoCleanUp = true) {
const dir = await fsExtra.mkdtemp(path.resolve(os.tmpdir(), 'electron-update-spec-')); const dir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-update-spec-'));
try { try {
await fn(dir); await fn(dir);
} finally { } finally {

View file

@ -1,6 +1,6 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as childProcess from 'node:child_process'; import * as childProcess from 'node:child_process';
import * as fs from 'fs-extra'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import * as util from 'node:util'; import * as util from 'node:util';
import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers'; import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
@ -706,7 +706,7 @@ describe('node feature', () => {
return; return;
} }
const alienBinary = path.join(appPath, 'Contents/MacOS/node'); const alienBinary = path.join(appPath, 'Contents/MacOS/node');
await fs.copy(path.join(nodePath, 'node'), alienBinary); await fs.promises.cp(path.join(nodePath, 'node'), alienBinary, { recursive: true });
// Try to execute electron app from the alien node in app bundle. // Try to execute electron app from the alien node in app bundle.
const { code, out } = await spawn(alienBinary, [script, path.join(appPath, 'Contents/MacOS/Electron')]); const { code, out } = await spawn(alienBinary, [script, path.join(appPath, 'Contents/MacOS/Electron')]);
expect(code).to.equal(0); expect(code).to.equal(0);

View file

@ -810,13 +810,6 @@
"@types/qs" "*" "@types/qs" "*"
"@types/serve-static" "*" "@types/serve-static" "*"
"@types/fs-extra@^9.0.1":
version "9.0.1"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.1.tgz#91c8fc4c51f6d5dbe44c2ca9ab09310bd00c7918"
integrity sha512-B42Sxuaz09MhC3DDeW5kubRcQ5by4iuVQ0cRRWM2lggLzAa/KVom0Aft/208NgMvNQQZ86s5rVcqDdn/SH0/mg==
dependencies:
"@types/node" "*"
"@types/glob@^7.1.1": "@types/glob@^7.1.1":
version "7.1.1" version "7.1.1"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
@ -1573,11 +1566,6 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
available-typed-arrays@^1.0.5: available-typed-arrays@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
@ -3105,16 +3093,6 @@ fs-extra@^8.1.0:
jsonfile "^4.0.0" jsonfile "^4.0.0"
universalify "^0.1.0" universalify "^0.1.0"
fs-extra@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"
integrity sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^1.0.0"
fs-minipass@^2.0.0: fs-minipass@^2.0.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb"