@@ -116,15 +116,15 @@ async function osadecompile(filePath: string): Promise<string> {
116116 const { spawn } = require ( 'node:child_process' ) ;
117117 const process = spawn ( 'osadecompile' , [ filePath ] ) ;
118118
119- let stdout = '' ;
120- let stderr = '' ;
119+ const stdout : string [ ] = [ ] ;
120+ const stderr : string [ ] = [ ] ;
121121
122122 process . stdout . on ( 'data' , ( data : Buffer ) => {
123- stdout += data . toString ( ) ;
123+ stdout . push ( data . toString ( ) ) ;
124124 } ) ;
125125
126126 process . stderr . on ( 'data' , ( data : Buffer ) => {
127- stderr += data . toString ( ) ;
127+ stderr . push ( data . toString ( ) ) ;
128128 } ) ;
129129
130130 process . on ( 'close' , ( code : number ) => {
@@ -133,7 +133,7 @@ async function osadecompile(filePath: string): Promise<string> {
133133 console . error ( '[idleberg.applescript] osadecompile failed:' , error ) ;
134134 reject ( new Error ( `Failed to decompile ${ filePath } : ${ error } ` ) ) ;
135135 } else {
136- resolve ( stdout ) ;
136+ resolve ( stdout . join ( '' ) ) ;
137137 }
138138 } ) ;
139139
@@ -149,7 +149,7 @@ async function osadecompile(filePath: string): Promise<string> {
149149 * @param sourceCode AppleScript source code
150150 * @param outputPath Path where the compiled .scpt should be written
151151 */
152- async function osacompileFromSource ( sourceCode : string , outputPath : string ) : Promise < void > {
152+ async function osacompileFromSource ( sourceCode : string , outputPath : string ) : Promise < string > {
153153 const { ignoreOS } = await getConfig ( 'applescript' ) ;
154154
155155 if ( platform ( ) !== 'darwin' && ignoreOS !== true ) {
@@ -160,10 +160,15 @@ async function osacompileFromSource(sourceCode: string, outputPath: string): Pro
160160 const { spawn } = require ( 'node:child_process' ) ;
161161 const process = spawn ( 'osacompile' , [ '-o' , outputPath , '-' ] ) ;
162162
163- let stderr = '' ;
163+ const stdout : string [ ] = [ ] ;
164+ const stderr : string [ ] = [ ] ;
165+
166+ process . stdout . on ( 'data' , ( data : Buffer ) => {
167+ stdout . push ( data . toString ( ) ) ;
168+ } ) ;
164169
165170 process . stderr . on ( 'data' , ( data : Buffer ) => {
166- stderr += data . toString ( ) ;
171+ stderr . push ( data . toString ( ) ) ;
167172 } ) ;
168173
169174 process . on ( 'close' , ( code : number ) => {
@@ -172,7 +177,7 @@ async function osacompileFromSource(sourceCode: string, outputPath: string): Pro
172177 console . error ( '[idleberg.applescript] osacompile failed:' , error ) ;
173178 reject ( new Error ( `Failed to compile to ${ outputPath } : ${ error } ` ) ) ;
174179 } else {
175- resolve ( ) ;
180+ resolve ( stdout . join ( '' ) ) ;
176181 }
177182 } ) ;
178183
0 commit comments