File tree 6 files changed +27
-33
lines changed
6 files changed +27
-33
lines changed Original file line number Diff line number Diff line change 35
35
"devDependencies" : {
36
36
"@tsconfig/node22" : " ^22.0.0" ,
37
37
"@types/debug" : " ^4.1.12" ,
38
- "@types/graceful-fs" : " ^4.1.9" ,
39
38
"@types/node" : " ~22.10.7" ,
40
39
"@types/promise-retry" : " ^1.1.3" ,
41
40
"prettier" : " ^3.4.2" ,
46
45
},
47
46
"dependencies" : {
48
47
"debug" : " ^4.4.0" ,
49
- "graceful-fs" : " ^4.2.11" ,
50
48
"promise-retry" : " ^2.0.1"
51
49
}
52
50
}
Original file line number Diff line number Diff line change 1
- import * as path from 'path' ;
1
+ import path from 'node: path' ;
2
2
3
3
import { spawn } from './spawn.js' ;
4
4
import { NotaryToolNotarizeAppOptions } from './types.js' ;
Original file line number Diff line number Diff line change 1
1
import debug from 'debug' ;
2
- import * as fs from 'graceful-fs' ;
3
2
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 ' ;
7
6
8
7
const d = debug ( 'electron-notarize:helpers' ) ;
9
8
10
9
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-' ) ) ;
12
11
d ( 'doing work inside temp dir:' , dir ) ;
13
12
let result : T ;
14
13
try {
15
14
result = await fn ( dir ) ;
16
15
} catch ( err ) {
17
16
d ( 'work failed' ) ;
18
- await util . promisify ( fs . rm ) ( dir , { recursive : true , force : true } ) ;
17
+ await fs . promises . rm ( dir , { recursive : true , force : true } ) ;
19
18
throw err ;
20
19
}
21
20
d ( 'work succeeded' ) ;
22
- await util . promisify ( fs . rm ) ( dir , { recursive : true , force : true } ) ;
21
+ await fs . promises . rm ( dir , { recursive : true , force : true } ) ;
23
22
return result ;
24
23
}
25
24
Original file line number Diff line number Diff line change 1
1
import debug from 'debug' ;
2
- import * as path from 'path' ;
2
+ import path from 'node: path' ;
3
3
4
4
import { spawn } from './spawn.js' ;
5
5
import { NotaryToolNotarizeAppOptions } from './types.js' ;
Original file line number Diff line number Diff line change 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' ;
3
7
4
8
describe ( 'helpers' , ( ) => {
5
9
describe ( 'parseNotarizationInfo' , ( ) => {
6
- test ( 'build a NotarizationInfo object', ( ) => {
10
+ it ( 'builds a NotarizationInfo object', ( ) => {
7
11
const output = `
8
12
RequestUUID: 123
9
13
Date: 2020-01-01
@@ -16,4 +20,16 @@ Status: unknown
16
20
} ) ;
17
21
} ) ;
18
22
} ) ;
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
+ } ) ;
19
35
} ) ;
Original file line number Diff line number Diff line change 244
244
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
245
245
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==
246
246
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
-
254
247
" @types/ms@* " :
255
248
version "2.1.0"
256
249
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-2.1.0.tgz#052aa67a48eccc4309d7f0191b7e41434b90bb78"
257
250
integrity sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==
258
251
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
-
266
252
" @types/node@~22.10.7 " :
267
253
version "22.10.7"
268
254
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:
454
440
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
455
441
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
456
442
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
-
462
443
jsonc-parser@^3.2.0 :
463
444
version "3.2.1"
464
445
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.1.tgz#031904571ccf929d7670ee8c547545081cb37f1a"
You can’t perform that action at this time.
0 commit comments