Skip to content

Commit 451b6e7

Browse files
authored
fix: remove graceful-fs and use direct imports (#229)
--------- Co-authored-by: Charles Kerr <[email protected]> Co-authored-by: Mark Lee <[email protected]>
1 parent d086e4f commit 451b6e7

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"devDependencies": {
3636
"@tsconfig/node22": "^22.0.0",
3737
"@types/debug": "^4.1.12",
38-
"@types/graceful-fs": "^4.1.9",
3938
"@types/node": "~22.10.7",
4039
"@types/promise-retry": "^1.1.3",
4140
"prettier": "^3.4.2",
@@ -46,7 +45,6 @@
4645
},
4746
"dependencies": {
4847
"debug": "^4.4.0",
49-
"graceful-fs": "^4.2.11",
5048
"promise-retry": "^2.0.1"
5149
}
5250
}

src/check-signature.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'path';
1+
import path from 'node:path';
22

33
import { spawn } from './spawn.js';
44
import { NotaryToolNotarizeAppOptions } from './types.js';

src/helpers.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
import debug from 'debug';
2-
import * as fs from 'graceful-fs';
32

4-
import * as os from 'node:os';
5-
import * as path from 'node:path';
6-
import * as util from 'node:util';
3+
import fs from 'node:fs';
4+
import os from 'node:os';
5+
import path from 'node:path';
76

87
const d = debug('electron-notarize:helpers');
98

109
export async function withTempDir<T>(fn: (dir: string) => Promise<T>) {
11-
const dir = await util.promisify(fs.mkdtemp)(path.resolve(os.tmpdir(), 'electron-notarize-'));
10+
const dir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-notarize-'));
1211
d('doing work inside temp dir:', dir);
1312
let result: T;
1413
try {
1514
result = await fn(dir);
1615
} catch (err) {
1716
d('work failed');
18-
await util.promisify(fs.rm)(dir, { recursive: true, force: true });
17+
await fs.promises.rm(dir, { recursive: true, force: true });
1918
throw err;
2019
}
2120
d('work succeeded');
22-
await util.promisify(fs.rm)(dir, { recursive: true, force: true });
21+
await fs.promises.rm(dir, { recursive: true, force: true });
2322
return result;
2423
}
2524

src/staple.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import debug from 'debug';
2-
import * as path from 'path';
2+
import path from 'node:path';
33

44
import { spawn } from './spawn.js';
55
import { NotaryToolNotarizeAppOptions } from './types.js';

test/helpers.test.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import { describe, expect, test } from 'vitest';
2-
import { parseNotarizationInfo } from '../src/helpers';
1+
import fs from 'node:fs';
2+
import os from 'node:os';
3+
import path from 'node:path';
4+
5+
import { describe, expect, it } from 'vitest';
6+
import { parseNotarizationInfo, withTempDir } from '../src/helpers';
37

48
describe('helpers', () => {
59
describe('parseNotarizationInfo', () => {
6-
test('build a NotarizationInfo object', () => {
10+
it('builds a NotarizationInfo object', () => {
711
const output = `
812
RequestUUID: 123
913
Date: 2020-01-01
@@ -16,4 +20,16 @@ Status: unknown
1620
});
1721
});
1822
});
23+
24+
describe('withTempDir', async () => {
25+
it('creates a temporary directory and cleans it up afterwards', async () => {
26+
let tmp: string | undefined;
27+
await withTempDir(async (dir) => {
28+
tmp = dir;
29+
});
30+
expect(tmp).toBeDefined();
31+
expect(tmp).toContain(path.join(os.tmpdir(), 'electron-notarize-'));
32+
expect(fs.existsSync(tmp!)).toBe(false);
33+
});
34+
});
1935
});

yarn.lock

-19
Original file line numberDiff line numberDiff line change
@@ -244,25 +244,11 @@
244244
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
245245
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==
246246

247-
"@types/graceful-fs@^4.1.9":
248-
version "4.1.9"
249-
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4"
250-
integrity sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==
251-
dependencies:
252-
"@types/node" "*"
253-
254247
"@types/ms@*":
255248
version "2.1.0"
256249
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-2.1.0.tgz#052aa67a48eccc4309d7f0191b7e41434b90bb78"
257250
integrity sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==
258251

259-
"@types/node@*":
260-
version "22.13.10"
261-
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.13.10.tgz#df9ea358c5ed991266becc3109dc2dc9125d77e4"
262-
integrity sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==
263-
dependencies:
264-
undici-types "~6.20.0"
265-
266252
"@types/node@~22.10.7":
267253
version "22.10.7"
268254
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.7.tgz#14a1ca33fd0ebdd9d63593ed8d3fbc882a6d28d7"
@@ -454,11 +440,6 @@ fsevents@~2.3.2, fsevents@~2.3.3:
454440
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
455441
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
456442

457-
graceful-fs@^4.2.11:
458-
version "4.2.11"
459-
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
460-
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
461-
462443
jsonc-parser@^3.2.0:
463444
version "3.2.1"
464445
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.1.tgz#031904571ccf929d7670ee8c547545081cb37f1a"

0 commit comments

Comments
 (0)