Skip to content

Commit 0a61d4a

Browse files
author
Mitko-Kerezov
committed
Use spawn wherever possible
Wherever possible use `spawn` instead of `exec`. This minifies the chance of something going wrong wherever there are spaces, quotation marks and whatnots in the project's name. Addresses #1455
1 parent 398ac19 commit 0a61d4a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/services/ios-project-service.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
268268
let project = this.createPbxProj();
269269
let frameworkName = path.basename(frameworkPath, path.extname(frameworkPath));
270270
let frameworkBinaryPath = path.join(frameworkPath, frameworkName);
271-
let isDynamic = _.contains(this.$childProcess.exec(`otool -Vh ${frameworkBinaryPath}`).wait(), " DYLIB ");
271+
let isDynamic = _.contains(this.$childProcess.spawnFromEvent("otool", ["-Vh", frameworkBinaryPath], "close").wait().stdout, " DYLIB ");
272272

273273
let frameworkAddOptions: xcode.Options = { customFramework: true };
274274

@@ -577,7 +577,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
577577
this.$errors.failWithoutHelp("The bundle at %s does not contain an Info.plist file.", libraryPath);
578578
}
579579

580-
let packageType = this.$childProcess.exec(`/usr/libexec/PlistBuddy -c "Print :CFBundlePackageType" "${infoPlistPath}"`).wait().trim();
580+
let packageType = this.$childProcess.spawnFromEvent("/usr/libexec/PlistBuddy", ["-c", "Print :CFBundlePackageType", infoPlistPath], "close").wait().stdout.trim();
581581
if (packageType !== "FMWK") {
582582
this.$errors.failWithoutHelp("The bundle at %s does not appear to be a dynamic framework.", libraryPath);
583583
}
@@ -761,8 +761,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
761761
if (!this.$fs.exists(projectFile).wait()) {
762762
this.$fs.writeFile(projectFile, "").wait();
763763
}
764-
765-
let mergeScript = `require 'xcodeproj'; Xcodeproj::Config.new('${projectFile}').merge(Xcodeproj::Config.new('${pluginFile}')).save_as(Pathname.new('${projectFile}'))`;
764+
765+
let escapedProjectFile = projectFile.replace(/'/g, "\\'"),
766+
escapedPluginFile = pluginFile.replace(/'/g, "\\'"),
767+
mergeScript = `require 'xcodeproj'; Xcodeproj::Config.new('${escapedProjectFile}').merge(Xcodeproj::Config.new('${escapedPluginFile}')).save_as(Pathname.new('${escapedProjectFile}'))`;
766768
this.$childProcess.exec(`ruby -e "${mergeScript}"`).wait();
767769
}).future<void>()();
768770
}

0 commit comments

Comments
 (0)