@@ -2,6 +2,7 @@ import { Types } from '@graphql-codegen/plugin-helpers';
22import { debugLog } from './utils/debugging.js' ;
33import { exec } from 'child_process' ;
44import { delimiter , sep } from 'path' ;
5+ import { quote } from 'shell-quote' ;
56
67const DEFAULT_HOOKS : Types . LifecycleHooksDefinition < string [ ] > = {
78 afterStart : [ ] ,
@@ -76,10 +77,11 @@ async function executeHooks(
7677) : Promise < void > {
7778 debugLog ( `Running lifecycle hook "${ hookName } " scripts...` ) ;
7879
80+ const quotedArgs = quote ( args ) ;
7981 for ( const script of scripts ) {
8082 if ( typeof script === 'string' ) {
81- debugLog ( `Running lifecycle hook "${ hookName } " script: ${ script } with args: ${ args . join ( ' ' ) } ...` ) ;
82- await execShellCommand ( `${ script } ${ args . join ( ' ' ) } ` ) ;
83+ debugLog ( `Running lifecycle hook "${ hookName } " script: ${ script } with args: ${ quotedArgs } ...` ) ;
84+ await execShellCommand ( `${ script } ${ quotedArgs } ` ) ;
8385 } else {
8486 debugLog ( `Running lifecycle hook "${ hookName } " script: ${ script . name } with args: ${ args . join ( ' ' ) } ...` ) ;
8587 await script ( ...args ) ;
@@ -94,7 +96,7 @@ export const lifecycleHooks = (_hooks: Partial<Types.LifecycleHooksDefinition> =
9496 afterStart : async ( ) : Promise < void > => executeHooks ( 'afterStart' , hooks . afterStart ) ,
9597 onWatchTriggered : async ( event : string , path : string ) : Promise < void > =>
9698 executeHooks ( 'onWatchTriggered' , hooks . onWatchTriggered , [ event , path ] ) ,
97- onError : async ( error : string ) : Promise < void > => executeHooks ( 'onError' , hooks . onError , [ `" ${ error } "` ] ) ,
99+ onError : async ( error : string ) : Promise < void > => executeHooks ( 'onError' , hooks . onError , [ error ] ) ,
98100 afterOneFileWrite : async ( path : string ) : Promise < void > =>
99101 executeHooks ( 'afterOneFileWrite' , hooks . afterOneFileWrite , [ path ] ) ,
100102 afterAllFileWrite : async ( paths : string [ ] ) : Promise < void > =>
0 commit comments