Skip to content

Commit 3fb1aab

Browse files
committed
[refactor] DRY up addPluginFiles
1 parent faf4114 commit 3fb1aab

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

lib/pbxProject.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,43 +72,39 @@ pbxProject.prototype.generateUuid = function () {
7272
}
7373
}
7474

75-
pbxProject.prototype.addSourceFile = function (path, opt) {
75+
pbxProject.prototype.addPluginFile = function (path, opt) {
7676
var file = new pbxFile(path, opt);
7777

78-
file.uuid = this.generateUuid();
79-
file.fileRef = this.generateUuid();
8078
correctForPluginsPath(file, this);
79+
file.fileRef = this.generateUuid();
8180

82-
this.addToPbxBuildFileSection(file); // PBXBuildFile
8381
this.addToPbxFileReferenceSection(file); // PBXFileReference
8482
this.addToPluginsPbxGroup(file); // PBXGroup
85-
this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase
8683

8784
return file;
8885
}
8986

90-
pbxProject.prototype.addHeaderFile = function (path, opt) {
91-
var file = new pbxFile(path, opt);
87+
pbxProject.prototype.addSourceFile = function (path, opt) {
88+
var file = this.addPluginFile(path, opt)
9289

93-
file.fileRef = this.generateUuid();
94-
correctForPluginsPath(file, this);
90+
file.uuid = this.generateUuid();
9591

96-
this.addToPbxFileReferenceSection(file); // PBXFileReference
97-
this.addToPluginsPbxGroup(file); // PBXGroup
92+
this.addToPbxBuildFileSection(file); // PBXBuildFile
93+
this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase
9894

9995
return file;
10096
}
10197

98+
pbxProject.prototype.addHeaderFile = function (path, opt) {
99+
return this.addPluginFile(path, opt)
100+
}
101+
102102
pbxProject.prototype.addResourceFile = function (path, opt) {
103-
var file = new pbxFile(path, opt);
103+
var file = this.addPluginFile(path, opt)
104104

105105
file.uuid = this.generateUuid();
106-
file.fileRef = this.generateUuid();
107-
correctForPluginsPath(file, this);
108106

109107
this.addToPbxBuildFileSection(file); // PBXBuildFile
110-
this.addToPbxFileReferenceSection(file); // PBXFileReference
111-
this.addToPluginsPbxGroup(file); // PBXGroup
112108
this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
113109

114110
return file;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Andrew Lunny <alunny@gmail.com>",
33
"name": "xcode",
44
"description": "parser for xcodeproj/project.pbxproj files",
5-
"version": "0.4.0",
5+
"version": "0.4.1",
66
"main":"index.js",
77
"repository": {
88
"url": "https://github.com/alunny/node-xcode.git"

0 commit comments

Comments
 (0)