File tree Expand file tree Collapse file tree 6 files changed +27
-33
lines changed
Expand file tree Collapse file tree 6 files changed +27
-33
lines changed Original file line number Diff line number Diff line change 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" ,
4645 },
4746 "dependencies" : {
4847 "debug" : " ^4.4.0" ,
49- "graceful-fs" : " ^4.2.11" ,
5048 "promise-retry" : " ^2.0.1"
5149 }
5250}
Original file line number Diff line number Diff line change 1- import * as path from 'path' ;
1+ import path from 'node: path' ;
22
33import { spawn } from './spawn.js' ;
44import { NotaryToolNotarizeAppOptions } from './types.js' ;
Original file line number Diff line number Diff line change 11import 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
87const d = debug ( 'electron-notarize:helpers' ) ;
98
109export 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
Original file line number Diff line number Diff line change 11import debug from 'debug' ;
2- import * as path from 'path' ;
2+ import path from 'node: path' ;
33
44import { spawn } from './spawn.js' ;
55import { 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' ;
37
48describe ( 'helpers' , ( ) => {
59 describe ( 'parseNotarizationInfo' , ( ) => {
6- test ( 'build a NotarizationInfo object', ( ) => {
10+ it ( 'builds a NotarizationInfo object', ( ) => {
711 const output = `
812RequestUUID: 123
913Date: 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} ) ;
Original file line number Diff line number Diff line change 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-
462443jsonc-parser@^3.2.0 :
463444 version "3.2.1"
464445 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