Skip to content

Commit e1f2a36

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #1 from NativeScript/fatme/improvements
Fix quotes and lastKnownFileType
2 parents f32bfed + 5c2e1e2 commit e1f2a36

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/pbxFile.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var path = require('path'),
66
DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
77
FRAMEWORK_EXTENSION = /[.]framework/, FRAMEWORK = 'wrapper.framework',
88
ARCHIVE_EXTENSION = /[.]a$/, ARCHIVE = 'archive.ar',
9+
PNG_EXTENSION = /[.]png/, PNG_IMAGE = "image.png",
910
DEFAULT_SOURCE_TREE = '"<group>"',
1011
DEFAULT_FILE_ENCODING = 4;
1112

@@ -30,13 +31,16 @@ function detectLastType(path) {
3031

3132
if (ARCHIVE_EXTENSION.test(path))
3233
return ARCHIVE;
33-
34+
35+
if (PNG_EXTENSION.test(path))
36+
return PNG_IMAGE;
37+
3438
// dunno
3539
return 'unknown';
3640
}
3741

3842
function fileEncoding(file) {
39-
if (file.lastType != BUNDLE && !file.customFramework) {
43+
if (file.lastType != BUNDLE && file.lastType !== PNG_IMAGE && !file.customFramework) {
4044
return DEFAULT_FILE_ENCODING;
4145
}
4246
}

lib/pbxProject.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,18 @@ function pbxFileReferenceObj(file) {
709709

710710
obj.isa = 'PBXFileReference';
711711
obj.lastKnownFileType = file.lastType;
712+
obj.name = file.basename;
713+
obj.path = file.path;
712714

713-
obj.name = "\"" + file.basename + "\"";
714-
obj.path = "\"" + file.path + "\"";
715+
if(obj.name.indexOf("\"") !== -1) {
716+
obj.name = obj.name.replace(/\"/g, "\\\"");
717+
obj.path = obj.path.replace(/\"/g, "\\\"");
718+
}
719+
720+
if(!file.basename.match(/^[a-zA-Z0-9_\.\$]+\.[a-zA-Z]+$/)) {
721+
obj.name = "\"" + obj.name + "\"";
722+
obj.path = "\"" + obj.path + "\"";
723+
}
715724

716725
obj.sourceTree = file.sourceTree;
717726

0 commit comments

Comments
 (0)