Comparing version 0.4.0 to 0.4.1
@@ -75,12 +75,10 @@ var util = require('util'), | ||
pbxProject.prototype.addSourceFile = function (path, opt) { | ||
pbxProject.prototype.addPluginFile = function (path, opt) { | ||
var file = new pbxFile(path, opt); | ||
file.uuid = this.generateUuid(); | ||
correctForPluginsPath(file, this); | ||
file.fileRef = this.generateUuid(); | ||
this.addToPbxBuildFileSection(file); // PBXBuildFile | ||
this.addToPbxFileReferenceSection(file); // PBXFileReference | ||
this.addToPluginsPbxGroup(file); // PBXGroup | ||
this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase | ||
@@ -90,9 +88,9 @@ return file; | ||
pbxProject.prototype.addHeaderFile = function (path, opt) { | ||
var file = new pbxFile(path, opt); | ||
pbxProject.prototype.addSourceFile = function (path, opt) { | ||
var file = this.addPluginFile(path, opt) | ||
file.fileRef = this.generateUuid(); | ||
file.uuid = this.generateUuid(); | ||
this.addToPbxFileReferenceSection(file); // PBXFileReference | ||
this.addToPluginsPbxGroup(file); // PBXGroup | ||
this.addToPbxBuildFileSection(file); // PBXBuildFile | ||
this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase | ||
@@ -102,11 +100,12 @@ return file; | ||
pbxProject.prototype.addHeaderFile = function (path, opt) { | ||
return this.addPluginFile(path, opt) | ||
} | ||
pbxProject.prototype.addResourceFile = function (path, opt) { | ||
var file = new pbxFile(path, opt); | ||
var file = this.addPluginFile(path, opt) | ||
file.uuid = this.generateUuid(); | ||
file.fileRef = this.generateUuid(); | ||
this.addToPbxBuildFileSection(file); // PBXBuildFile | ||
this.addToPbxFileReferenceSection(file); // PBXFileReference | ||
this.addToPluginsPbxGroup(file); // PBXGroup | ||
this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase | ||
@@ -282,2 +281,12 @@ | ||
// respect <group> path | ||
function correctForPluginsPath(file, project) { | ||
var r_plugin_dir = /^Plugins\//; | ||
if (project.pbxGroupByName('Plugins').path) | ||
file.path = file.path.replace(r_plugin_dir, ''); | ||
return file; | ||
} | ||
module.exports = pbxProject; |
@@ -5,3 +5,3 @@ { | ||
"description": "parser for xcodeproj/project.pbxproj files", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"main":"index.js", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -57,3 +57,3 @@ var fullProject = require('./fixtures/full-project') | ||
test.equal(fileRefEntry.name, 'file.h'); | ||
test.equal(fileRefEntry.path, 'Plugins/file.h'); | ||
test.equal(fileRefEntry.path, 'file.h'); | ||
test.equal(fileRefEntry.sourceTree, '"<group>"'); | ||
@@ -60,0 +60,0 @@ |
@@ -85,2 +85,4 @@ var fullProject = require('./fixtures/full-project') | ||
'should add the PBXFileReference object correctly': function (test) { | ||
delete proj.pbxGroupByName('Plugins').path; | ||
var newFile = proj.addResourceFile('Plugins/assets.bundle'), | ||
@@ -130,3 +132,17 @@ fileRefSection = proj.pbxFileReferenceSection(), | ||
test.done(); | ||
}, | ||
'should remove "Plugins/" from path if group path is set': function (test) { | ||
var plugins = proj.pbxGroupByName('Plugins'), | ||
newFile; | ||
plugins.path = '"Test200/Plugins"'; | ||
newFile = proj.addResourceFile('Plugins/assets.bundle'); | ||
test.equal(newFile.path, 'assets.bundle'); | ||
test.done(); | ||
}, | ||
tearDown: function (callback) { | ||
delete proj.pbxGroupByName('Plugins').path; | ||
callback(); | ||
} | ||
} |
@@ -93,3 +93,3 @@ var fullProject = require('./fixtures/full-project') | ||
test.equal(fileRefEntry.name, 'file.m'); | ||
test.equal(fileRefEntry.path, 'Plugins/file.m'); | ||
test.equal(fileRefEntry.path, 'file.m'); | ||
test.equal(fileRefEntry.sourceTree, '"<group>"'); | ||
@@ -96,0 +96,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213701
3835