Skip to content

Commit 5c9c2c6

Browse files
committed
feat: Add support various file extensions and export filetypes for pbxFile module
1 parent 08846bb commit 5c9c2c6

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

lib/pbxFile.js

+41-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
var path = require('path'),
1+
var $path = require('path'),
22
util = require('util'),
33
M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
4+
C_EXTENSION = /[.]c$/, C_SOURCE_FILE = 'sourcecode.c',
45
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
6+
MM_EXTENSION = /[.]mm$/, MM_SOURCE_FILE = 'sourcecode.cpp.objcpp',
7+
HPP_EXTENSION = /[.](hpp|hxx|h\+\+|hh)$/, CPP_HEADER_FILE = 'sourcecode.cpp.h',
8+
CPP_EXTENSION = /[.](cpp|cxx|c\+\+|cc)$/, CPP_SOURCE_FILE = 'sourcecode.cpp.cpp',
59
BUNDLE_EXTENSION = /[.]bundle$/, BUNDLE = '"wrapper.plug-in"',
610
XIB_EXTENSION = /[.]xib$/, XIB_FILE = 'file.xib',
711
DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
@@ -11,13 +15,42 @@ var path = require('path'),
1115
DEFAULT_SOURCE_TREE = '"<group>"',
1216
DEFAULT_FILE_ENCODING = 4;
1317

18+
function fileTypes() {
19+
return {
20+
SOURCE_FILE,
21+
C_SOURCE_FILE,
22+
HEADER_FILE,
23+
MM_SOURCE_FILE,
24+
CPP_HEADER_FILE,
25+
CPP_SOURCE_FILE,
26+
BUNDLE,
27+
XIB_FILE,
28+
FRAMEWORK,
29+
DYLIB,
30+
ARCHIVE,
31+
PNG_IMAGE,
32+
}
33+
}
34+
1435
function detectLastType(path) {
1536
if (M_EXTENSION.test(path))
1637
return SOURCE_FILE;
1738

39+
if (C_EXTENSION.test(path))
40+
return C_SOURCE_FILE;
41+
1842
if (H_EXTENSION.test(path))
1943
return HEADER_FILE;
2044

45+
if (MM_EXTENSION.test(path))
46+
return MM_SOURCE_FILE;
47+
48+
if (CPP_EXTENSION.test(path))
49+
return CPP_SOURCE_FILE;
50+
51+
if (HPP_EXTENSION.test(path))
52+
return CPP_HEADER_FILE;
53+
2154
if (BUNDLE_EXTENSION.test(path))
2255
return BUNDLE;
2356

@@ -82,17 +115,17 @@ function pbxFile(filepath, opt) {
82115
// for custom frameworks
83116
if(opt.customFramework == true) {
84117
this.customFramework = true;
85-
this.dirname = path.dirname(filepath);
118+
this.dirname = $path.dirname(filepath);
86119
}
87120

88-
this.basename = path.basename(filepath);
121+
this.basename = $path.basename(filepath);
89122
this.path = correctPath(this, filepath);
90123
this.group = correctGroup(this);
91124

92125
this.sourceTree = opt.sourceTree || defaultSourceTree(this);
93126
this.fileEncoding = opt.fileEncoding || fileEncoding(this);
94127

95-
if (opt.weak && opt.weak === true)
128+
if (opt.weak && opt.weak === true)
96129
this.settings = { ATTRIBUTES: ['Weak'] };
97130

98131
if (opt.compilerFlags) {
@@ -102,4 +135,7 @@ function pbxFile(filepath, opt) {
102135
}
103136
}
104137

105-
module.exports = pbxFile;
138+
module.exports = {
139+
pbxFile: pbxFile,
140+
fileTypes: fileTypes
141+
}

0 commit comments

Comments
 (0)