Skip to content

Commit d68d209

Browse files
committed
Use execFileSync over execSync when messing with file paths in generate-artifacts.js
1 parent a12d869 commit d68d209

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

scripts/generate-artifacts.js

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* in a CODEGEN_CONFIG_FILENAME file.
1717
*/
1818

19-
const {execSync} = require('child_process');
19+
const {execSync, execFileSync} = require('child_process');
2020
const fs = require('fs');
2121
const os = require('os');
2222
const path = require('path');
@@ -234,35 +234,45 @@ function main(appRootDir, outputPath) {
234234

235235
console.log(`\n\n[Codegen] >>>>> Processing ${library.config.name}`);
236236
// Generate one schema for the entire library...
237-
execSync(
238-
`node ${path.join(
237+
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
238+
execFileSync(
239+
'node',
240+
path.join(
239241
codegenCliPath,
240242
'lib',
241243
'cli',
242244
'combine',
243245
'combine-js-to-schema-cli.js',
244-
)} ${pathToSchema} ${pathToJavaScriptSources}`,
245-
);
246+
),
247+
pathToSchema,
248+
pathToJavaScriptSources,
249+
); // ]TODO(macOS GH#774)
246250
console.log(`[Codegen] Generated schema: ${pathToSchema}`);
247251

248252
// ...then generate native code artifacts.
249253
const libraryTypeArg = library.config.type
250254
? `--libraryType ${library.config.type}`
251255
: '';
252256
fs.mkdirSync(pathToTempOutputDir, {recursive: true});
253-
execSync(
254-
`node ${path.join(
255-
RN_ROOT,
256-
'scripts',
257-
'generate-specs-cli.js',
258-
)} --platform ios --schemaPath ${pathToSchema} --outputDir ${pathToTempOutputDir} --libraryName ${
259-
library.config.name
260-
} ${libraryTypeArg}`,
261-
);
257+
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
258+
execFileSync(
259+
'node',
260+
path.join(RN_ROOT, 'scripts', 'generate-specs-cli.js'),
261+
'--platform',
262+
'ios',
263+
'--schemaPath',
264+
pathToSchema,
265+
'--outputDir',
266+
pathToTempOutputDir,
267+
'--libraryName',
268+
library.config.name,
269+
libraryTypeArg,
270+
); // ]TODO(macOS GH#774)
262271

263272
// Finally, copy artifacts to the final output directory.
264273
fs.mkdirSync(pathToOutputDirIOS, {recursive: true});
265-
execSync(`cp -R ${pathToTempOutputDir}/* ${pathToOutputDirIOS}`);
274+
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
275+
execFileSync('cp', '-R', `${pathToTempOutputDir}/*`, pathToOutputDirIOS); // ]TODO(macOS GH#774)
266276
console.log(`[Codegen] Generated artifacts: ${pathToOutputDirIOS}`);
267277

268278
// Filter the react native core library out.
@@ -284,13 +294,17 @@ function main(appRootDir, outputPath) {
284294

285295
// Generate FabricComponentProvider.
286296
// Only for iOS at this moment.
287-
execSync(
288-
`node ${path.join(
289-
RN_ROOT,
290-
'scripts',
291-
'generate-provider-cli.js',
292-
)} --platform ios --schemaListPath "${schemaListTmpPath}" --outputDir ${iosOutputDir}`,
293-
);
297+
// [TODO(macOS GH#774) - use execFileSync to help keep shell commands clean
298+
execFileSync(
299+
'node',
300+
path.join(RN_ROOT, 'scripts', 'generate-provider-cli.js'),
301+
'--platform',
302+
'ios',
303+
'--schemaListPast',
304+
schemaListTmpPath,
305+
'--outputDir',
306+
iosOutputDir,
307+
); // ]TODO(macOS GH#774)
294308
console.log(`Generated provider in: ${iosOutputDir}`);
295309
}
296310
} catch (err) {

0 commit comments

Comments
 (0)