@@ -11,17 +11,10 @@ import updateCommand from '@oclif/plugin-update/lib/commands/update';
1111import { HttpToolkitServerApi } from './api-server' ;
1212import { checkBrowserConfig } from './browsers' ;
1313import { reportError } from './error-tracking' ;
14- import { delay , ALLOWED_ORIGINS } from './util' ;
14+ import { ALLOWED_ORIGINS } from './constants' ;
15+ import { delay , readFile , checkAccess , writeFile , ensureDirectoryExists } from './util' ;
1516import { registerShutdownHandler } from './shutdown' ;
1617
17- const canAccess = util . promisify ( fs . access ) ;
18- const mkDir = util . promisify ( fs . mkdir ) ;
19- const readFile = util . promisify ( fs . readFile ) ;
20- const writeFile = util . promisify ( fs . writeFile ) ;
21-
22- const ensureDirectoryExists = ( path : string ) =>
23- canAccess ( path ) . catch ( ( ) => mkDir ( path , { recursive : true } ) ) ;
24-
2518async function generateHTTPSConfig ( configPath : string ) {
2619 const keyPath = path . join ( configPath , 'ca.key' ) ;
2720 const certPath = path . join ( configPath , 'ca.pem' ) ;
@@ -31,7 +24,7 @@ async function generateHTTPSConfig(configPath: string) {
3124 checkCertExpiry ( certContent ) ;
3225 return certContent ;
3326 } ) ,
34- canAccess ( keyPath , fs . constants . R_OK ) ,
27+ checkAccess ( keyPath , fs . constants . R_OK ) ,
3528 ] ) . catch ( async ( ) => {
3629 // Cert doesn't exist, or is too close/past expiry. Generate a new one:
3730
0 commit comments