Skip to content

Commit b732ae5

Browse files
Chris BrodykspearrinChristopher J. Brody
authored
Resolve issue with pbxFile extension (alunny#31)
where pbxFile extension was being set to 'undefined' and add new test case to verify the bug fix with a quick test fix by @brodybits (Christopher J. Brody) for the sake of consistency with the other test cases NOTE: These changes were originally part of apache/cordova-node-xcode#12 (cordova-node-xcode PR alunny#12), extracted here by @brodybits. Co-authored-by: Kyle Spearrin <[email protected]> Co-authored-by: Christopher J. Brody <[email protected]>
1 parent 72daa2d commit b732ae5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/pbxFile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var FILETYPE_BY_EXTENSION = {
8383

8484

8585
function unquoted(text){
86-
return text.replace (/(^")|("$)/g, '')
86+
return text == null ? '' : text.replace (/(^")|("$)/g, '')
8787
}
8888

8989
function detectType(filePath) {
@@ -98,11 +98,12 @@ function detectType(filePath) {
9898
}
9999

100100
function defaultExtension(fileRef) {
101-
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
101+
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ?
102+
fileRef.lastKnownFileType : fileRef.explicitFileType;
102103

103104
for(var extension in FILETYPE_BY_EXTENSION) {
104105
if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) {
105-
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === filetype )
106+
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) )
106107
return extension;
107108
}
108109
}

test/pbxFile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,13 @@ exports['settings'] = {
278278

279279
test.deepEqual({COMPILER_FLAGS:'"-std=c++11 -fno-objc-arc"'}, sourceFile.settings);
280280
test.done();
281+
},
282+
283+
'should be .appex if {explicitFileType:\'"wrapper.app-extension"\'} specified': function (test) {
284+
var sourceFile = new pbxFile('AppExtension',
285+
{ explicitFileType: '"wrapper.app-extension"'});
286+
287+
test.equal('AppExtension.appex', sourceFile.basename);
288+
test.done();
281289
}
282290
}

0 commit comments

Comments
 (0)