@@ -68,6 +68,10 @@ export function getDockerComposeService(): string {
6868/**
6969 * Build the shell command line that runs a MageForge CLI command.
7070 * All arguments are safely quoted to prevent shell injection.
71+ * The MageForge command name itself is not quoted because it is always a
72+ * known, hard-coded CLI identifier (e.g. `mageforge:theme:build`); escaping
73+ * its colons makes the generated command hard to read and can confuse
74+ * containerized PHP wrappers.
7175 */
7276export function buildCommandLine (
7377 magentoRoot : string ,
@@ -79,26 +83,27 @@ export function buildCommandLine(
7983 . get < string > ( 'phpBinary' , 'php' ) ;
8084 const env = getExecutionEnvironment ( magentoRoot ) ;
8185
86+ const quote = ( parts : string [ ] ) : string => shellQuote . quote ( parts ) ;
87+
88+ function buildLine ( baseParts : string [ ] ) : string {
89+ const base = quote ( baseParts ) ;
90+ const quotedArgs = args . length > 0 ? ` ${ quote ( args ) } ` : '' ;
91+ return `${ base } ${ mageforgeCommand } ${ quotedArgs } ` ;
92+ }
93+
8294 switch ( env ) {
8395 case 'ddev' :
84- return shellQuote . quote ( [ 'ddev' , 'php' , 'bin/magento' , mageforgeCommand , ... args ] ) ;
96+ return buildLine ( [ 'ddev' , 'php' , 'bin/magento' ] ) ;
8597 case 'docker-compose' : {
8698 const service = getDockerComposeService ( ) ;
87- return shellQuote . quote ( [
88- 'docker-compose' ,
89- 'exec' ,
90- service ,
91- 'bin/magento' ,
92- mageforgeCommand ,
93- ...args ,
94- ] ) ;
99+ return buildLine ( [ 'docker-compose' , 'exec' , service , 'bin/magento' ] ) ;
95100 }
96101 case 'lando' :
97- return shellQuote . quote ( [ 'lando' , 'php' , 'bin/magento' , mageforgeCommand , ... args ] ) ;
102+ return buildLine ( [ 'lando' , 'php' , 'bin/magento' ] ) ;
98103 default : {
99104 // phpBinary can be a full command like "docker-compose exec php" or just "php"
100105 const phpParts = shellQuote . parse ( phpBinary ) as string [ ] ;
101- return shellQuote . quote ( [ ...phpParts , 'bin/magento' , mageforgeCommand , ... args ] ) ;
106+ return buildLine ( [ ...phpParts , 'bin/magento' ] ) ;
102107 }
103108 }
104109}
0 commit comments