Skip to content

Commit 9731e8e

Browse files
kittenfacebook-github-bot
authored andcommitted
Replace execSync with spawnSync for tarball extraction paths that need to be escaped (#53540)
Summary: Follow-up to #53194 This wasn't previously visible in testing without prebuilds and without a release build. This doesn't show up in debug builds. When testing more against paths that contain spaces, I noticed that release builds can still run into trouble due to the use of `execSync` without escaping paths. While, in other scripts that aren't used in user-projects (afaict), we often escape with quotes and rely on `execSync` calling the shell (due to its `shell: true` default), in some scripts we don't have quote escapes. That said, since paths could in theory contain quotes, adding quotes wouldn't be sufficient. Instead, since the affected `tar` calls are really trivial, we can instead use `spawnSync` with the `shell: false` default, which escapes arguments automatically. ## Changelog: [IOS] [FIXED] - fix Node scripts related to prebuilt tarball extraction for paths containing whitespaces Pull Request resolved: #53540 Test Plan: - Create a project in a folder `with spaces` and build a release build Reviewed By: cipolleschi, cortinico Differential Revision: D81406841 Pulled By: robhogan fbshipit-source-id: 08bb06b2cd2b15dc17c2f95fab9024129deca6f3
1 parent 727caca commit 9731e8e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

packages/react-native/scripts/replace-rncore-version.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
const {execSync} = require('child_process');
13+
const {spawnSync} = require('child_process');
1414
const fs = require('fs');
1515
const yargs = require('yargs');
1616

@@ -67,7 +67,9 @@ function replaceRNCoreConfiguration(
6767
fs.mkdirSync(finalLocation, {recursive: true});
6868

6969
console.log('Extracting the tarball', tarballURLPath);
70-
execSync(`tar -xf ${tarballURLPath} -C ${finalLocation}`);
70+
spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {
71+
stdio: 'inherit',
72+
});
7173
}
7274

7375
function updateLastBuildConfiguration(configuration /*: string */) {

packages/react-native/sdks/hermes-engine/utils/replace_hermes_version.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
const {execSync} = require('child_process');
13+
const {spawnSync} = require('child_process');
1414
const fs = require('fs');
1515
const yargs = require('yargs');
1616

@@ -62,7 +62,9 @@ function replaceHermesConfiguration(configuration, version, podsRoot) {
6262
fs.mkdirSync(finalLocation, {recursive: true});
6363

6464
console.log('Extracting the tarball');
65-
execSync(`tar -xf ${tarballURLPath} -C ${finalLocation}`);
65+
spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {
66+
stdio: 'inherit',
67+
});
6668
}
6769

6870
function updateLastBuildConfiguration(configuration) {

packages/react-native/third-party-podspecs/replace_dependencies_version.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
const {execSync} = require('child_process');
13+
const {spawnSync} = require('child_process');
1414
const fs = require('fs');
1515
const yargs = require('yargs');
1616

@@ -66,7 +66,9 @@ function replaceRNDepsConfiguration(
6666
fs.mkdirSync(finalLocation, {recursive: true});
6767

6868
console.log('Extracting the tarball', tarballURLPath);
69-
execSync(`tar -xf ${tarballURLPath} -C ${finalLocation}`);
69+
spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {
70+
stdio: 'inherit',
71+
});
7072

7173
// Now we need to remove the extra third-party folder as we do in the podspec's prepare-script
7274
// We need to take the ReactNativeDependencies.xcframework folder and move it up one level

0 commit comments

Comments
 (0)