@@ -7,6 +7,7 @@ import type {
77import type { PolykeyAgent } from 'polykey' ;
88import fs from 'fs' ;
99import process from 'process' ;
10+ import { fileURLToPath } from 'node:url' ;
1011/**
1112 * Hack for wiping out the threads signal handlers
1213 * See: https://github.com/andywer/threads.js/issues/388
@@ -15,7 +16,6 @@ import process from 'process';
1516 * in the entire codebase for this hack to work
1617 * If the worker manager is used, it must be stopped gracefully with the PolykeyAgent
1718 */
18- import 'threads' ;
1919import url from 'node:url' ;
2020process . removeAllListeners ( 'SIGINT' ) ;
2121process . removeAllListeners ( 'SIGTERM' ) ;
@@ -25,7 +25,8 @@ process.removeAllListeners('SIGTERM');
2525 * This can be referred to globally.
2626 * For ESM, change to using `import.meta.url`.
2727 */
28- globalThis . PK_MAIN_EXECUTABLE = __filename ;
28+ const filename = fileURLToPath ( import . meta. url ) ;
29+ globalThis . PK_MAIN_EXECUTABLE = filename ;
2930
3031async function polykeyAgentMain ( ) : Promise < number > {
3132 const {
@@ -146,7 +147,7 @@ async function polykeyAgentMain(): Promise<number> {
146147}
147148
148149async function polykeyMain ( argv : Array < string > ) : Promise < number > {
149- const { default : commander } = await import ( 'commander' ) ;
150+ const { CommanderError } = await import ( 'commander' ) ;
150151 const { default : ErrorPolykey } = await import ( 'polykey/ErrorPolykey.js' ) ;
151152 const { default : CommandBootstrap } = await import ( './bootstrap/index.js' ) ;
152153 const { default : CommandAgent } = await import ( './agent/index.js' ) ;
@@ -194,7 +195,7 @@ async function polykeyMain(argv: Array<string>): Promise<number> {
194195 process . exitCode = 0 ;
195196 } catch ( e ) {
196197 const errFormat = rootCommand . opts ( ) . format === 'json' ? 'json' : 'error' ;
197- if ( e instanceof commander . CommanderError ) {
198+ if ( e instanceof CommanderError ) {
198199 // Commander writes help and error messages on stderr automatically
199200 if (
200201 e . code === 'commander.help' ||
0 commit comments