Skip to content

Commit

Permalink
Resolve issue with pbxFile extension (#31)
Browse files Browse the repository at this point in the history
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
#12 (cordova-node-xcode PR #12),
extracted here by @brodybits.

Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
Co-authored-by: Christopher J. Brody <brodybits@litehelpers.net>
  • Loading branch information
3 people committed Dec 11, 2018
1 parent 72daa2d commit b732ae5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/pbxFile.js
Expand Up @@ -83,7 +83,7 @@ var FILETYPE_BY_EXTENSION = {


function unquoted(text){
return text.replace (/(^")|("$)/g, '')
return text == null ? '' : text.replace (/(^")|("$)/g, '')
}

function detectType(filePath) {
Expand All @@ -98,11 +98,12 @@ function detectType(filePath) {
}

function defaultExtension(fileRef) {
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ?
fileRef.lastKnownFileType : fileRef.explicitFileType;

for(var extension in FILETYPE_BY_EXTENSION) {
if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) {
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === filetype )
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) )
return extension;
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/pbxFile.js
Expand Up @@ -278,5 +278,13 @@ exports['settings'] = {

test.deepEqual({COMPILER_FLAGS:'"-std=c++11 -fno-objc-arc"'}, sourceFile.settings);
test.done();
},

'should be .appex if {explicitFileType:\'"wrapper.app-extension"\'} specified': function (test) {
var sourceFile = new pbxFile('AppExtension',
{ explicitFileType: '"wrapper.app-extension"'});

test.equal('AppExtension.appex', sourceFile.basename);
test.done();
}
}

0 comments on commit b732ae5

Please sign in to comment.