@@ -28,11 +28,14 @@ export class ScriptManager {
28
28
// Replace any unescaped quotes with escaped quotes
29
29
return `"${ arg . replace ( / " / g, '\\"' ) } "` ;
30
30
} ) ;
31
-
31
+
32
+ // Quote the script path to handle spaces
33
+ const quotedScriptPath = `"${ scriptPath } "` ;
34
+
32
35
let cmd = scriptConfig . interpreter
33
- ? `${ scriptConfig . interpreter } ${ scriptPath } ${ escapedArgs . join ( ' ' ) } `
34
- : `${ scriptPath } ${ escapedArgs . join ( ' ' ) } ` ;
35
-
36
+ ? `" ${ scriptConfig . interpreter } " ${ quotedScriptPath } ${ escapedArgs . join ( ' ' ) } `
37
+ : `${ quotedScriptPath } ${ escapedArgs . join ( ' ' ) } ` ;
38
+
36
39
// check if command is executable
37
40
this . plugin . log ( `Running script: ${ scriptPath } , with interpreter: ${ interpreter } ` , 'verbose' ) ;
38
41
if ( ! this . isRunnable ( interpreter , scriptPath ) ) {
@@ -45,11 +48,11 @@ export class ScriptManager {
45
48
}
46
49
return ;
47
50
}
48
-
51
+
49
52
if ( this . settings . verbosity === 'verbose' ) {
50
53
this . plugin . log ( `Executing command: ${ cmd } ` , 'verbose' ) ;
51
54
}
52
-
55
+
53
56
let scriptStartTime = Date . now ( ) ;
54
57
exec ( cmd , ( error , stdout , stderr ) => {
55
58
// Handle output based on scriptConfig.output
@@ -65,13 +68,13 @@ export class ScriptManager {
65
68
}
66
69
}
67
70
}
68
-
71
+
69
72
// Handle errors
70
73
if ( error ) {
71
74
new Notice ( 'Error executing script.' , 5000 ) ;
72
75
this . plugin . log ( 'Error executing script:' , "silent" ) ;
73
76
}
74
-
77
+
75
78
const scriptEndTime = Date . now ( ) ;
76
79
const scriptDuration = scriptEndTime - scriptStartTime ;
77
80
new Notice ( `Script executed successfully (took ${ scriptDuration } ms), output: ${ stdout } ` , 5000 ) ;
0 commit comments