Skip to content

Commit 4cca2f6

Browse files
author
Anis Kadri
committed
Merge branch 'sundbry-shell-step'
2 parents e686ab7 + cab0d0d commit 4cca2f6

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

lib/pbxProject.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
811811
return { uuid: target, target: nativeTargets[target] };
812812
}
813813

814-
pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, folderType, subfolderPath) {
814+
pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) {
815815
var buildPhaseSection,
816816
fileReferenceSection = this.pbxFileReferenceSection(),
817817
buildFileSection = this.pbxBuildFileSection(),
@@ -827,7 +827,9 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co
827827
filePathToBuildFile = {};
828828

829829
if (buildPhaseType === 'PBXCopyFilesBuildPhase') {
830-
buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, folderType, subfolderPath, comment);
830+
buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment);
831+
} else if (buildPhaseType === 'PBXShellScriptBuildPhase') {
832+
buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment)
831833
}
832834

833835
if (!this.hash.project.objects[buildPhaseType]) {
@@ -1490,7 +1492,7 @@ function pbxBuildPhaseObj(file) {
14901492
return obj;
14911493
}
14921494

1493-
function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName){
1495+
function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) {
14941496

14951497
// Add additional properties for 'CopyFiles' build phase
14961498
var DESTINATION_BY_TARGETTYPE = {
@@ -1527,6 +1529,16 @@ function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName){
15271529
return obj;
15281530
}
15291531

1532+
function pbxShellScriptBuildPhaseObj(obj, options, phaseName) {
1533+
obj.name = '"' + phaseName + '"';
1534+
obj.inputPaths = options.inputPaths || [];
1535+
obj.outputPaths = options.outputPaths || [];
1536+
obj.shellPath = options.shellPath;
1537+
obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"') + '"';
1538+
1539+
return obj;
1540+
}
1541+
15301542
function pbxBuildFileComment(file) {
15311543
return longComment(file);
15321544
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Andrew Lunny <alunny@gmail.com>",
33
"name": "xcode",
44
"description": "parser for xcodeproj/project.pbxproj files",
5-
"version": "0.8.9",
5+
"version": "0.9.0",
66
"main": "index.js",
77
"repository": {
88
"url": "https://github.com/alunny/node-xcode.git"
@@ -20,5 +20,6 @@
2020
},
2121
"scripts": {
2222
"test": "node_modules/.bin/nodeunit test/parser test"
23-
}
23+
},
24+
"license": "Apache-2.0"
2425
}

test/addBuildPhase.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,11 @@ exports.addBuildPhase = {
110110
test.equal(buildPhase.dstSubfolderSpec, 10);
111111
test.done();
112112
},
113+
'should add a script build phase to echo "hello world!"': function(test) {
114+
var options = {shellPath: '/bin/sh', shellScript: 'echo "hello world!"'};
115+
var buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase;
116+
test.equal(buildPhase.shellPath, '/bin/sh');
117+
test.equal(buildPhase.shellScript, '"echo \\"hello world!\\""');
118+
test.done();
119+
},
113120
}

0 commit comments

Comments
 (0)