|
1 | 1 | var $path = require('path'), |
2 | 2 | util = require('util'), |
| 3 | + HEADER_FILE_TYPE_SUFFIX = ".h", |
| 4 | + SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode.", |
3 | 5 | M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc', |
4 | 6 | C_EXTENSION = /[.]c$/, C_SOURCE_FILE = 'sourcecode.c', |
5 | 7 | H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h', |
@@ -32,6 +34,14 @@ function fileTypes() { |
32 | 34 | } |
33 | 35 | } |
34 | 36 |
|
| 37 | +function isSourceOrHeaderFileType(fileType) { |
| 38 | + return fileType.startsWith(SOURCE_CODE_FILE_TYPE_PREFIX); |
| 39 | +} |
| 40 | + |
| 41 | +function isHeaderFileType(fileType) { |
| 42 | + return fileType.endsWith(HEADER_FILE_TYPE_SUFFIX); |
| 43 | +} |
| 44 | + |
35 | 45 | function detectLastType(path) { |
36 | 46 | if (M_EXTENSION.test(path)) |
37 | 47 | return SOURCE_FILE; |
@@ -65,10 +75,10 @@ function detectLastType(path) { |
65 | 75 |
|
66 | 76 | if (ARCHIVE_EXTENSION.test(path)) |
67 | 77 | return ARCHIVE; |
68 | | - |
| 78 | + |
69 | 79 | if (PNG_EXTENSION.test(path)) |
70 | 80 | return PNG_IMAGE; |
71 | | - |
| 81 | + |
72 | 82 | // dunno |
73 | 83 | return 'unknown'; |
74 | 84 | } |
@@ -98,7 +108,7 @@ function correctPath(file, filepath) { |
98 | 108 | } |
99 | 109 |
|
100 | 110 | function correctGroup(file) { |
101 | | - if (file.lastType == SOURCE_FILE) { |
| 111 | + if (isSourceOrHeaderFileType(file.lastType) && !isHeaderFileType(file.lastType)) { |
102 | 112 | return 'Sources'; |
103 | 113 | } else if (file.lastType == DYLIB || file.lastType == ARCHIVE || file.lastType == FRAMEWORK) { |
104 | 114 | return 'Frameworks'; |
@@ -137,5 +147,7 @@ function pbxFile(filepath, opt) { |
137 | 147 |
|
138 | 148 | module.exports = { |
139 | 149 | pbxFile: pbxFile, |
140 | | - fileTypes: fileTypes |
| 150 | + fileTypes: fileTypes, |
| 151 | + isSourceOrHeaderFileType, |
| 152 | + isHeaderFileType, |
141 | 153 | } |
0 commit comments