From 710e426dd8730288e3e5d230ee4536b308ef40e5 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 16:49:47 +0900 Subject: [PATCH 01/22] chore: add eslint w/ config --- .eslintrc.yml | 22 ++++++++++++++++++++++ package.json | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .eslintrc.yml diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000..bedf0b7 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root: true +extends: '@cordova/eslint-config/node' + +# This will ignore the parser that is generated by pegjs +ignorePatterns: ['lib/parser/'] diff --git a/package.json b/package.json index 2493cc5..37246c0 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,14 @@ "uuid": "^7.0.3" }, "devDependencies": { + "@cordova/eslint-config": "^3.0.0", "nodeunit": "^0.11.3", "pegjs": "^0.10.0" }, "scripts": { "pegjs": "node_modules/.bin/pegjs lib/parser/pbxproj.pegjs", - "test": "node_modules/.bin/nodeunit test/parser test" + "test": "npm run lint && node_modules/.bin/nodeunit test/parser test", + "lint": "eslint ." }, "license": "Apache-2.0", "contributors": [ From 3160fc23b9c80fa1b0d2aca0063c82acdd4515c2 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 16:59:40 +0900 Subject: [PATCH 02/22] refactor: transform use multi-vars This is applied first before applying eslint's automated fix. With vars consolidated and split on new lines, eslint automated fix will correct the first line and leave the other lines untouched causing alot of variables not being declared. This will help the linting process. --- lib/parseJob.js | 10 +- lib/pbxFile.js | 103 ++++---- lib/pbxProject.js | 355 +++++++++++++++------------ lib/pbxWriter.js | 39 +-- test/BuildSettings.js | 11 +- test/FrameworkSearchPaths.js | 11 +- test/HeaderSearchPaths.js | 11 +- test/LibrarySearchPaths.js | 11 +- test/OtherLinkerFlags.js | 11 +- test/addBuildPhase.js | 59 ++--- test/addFramework.js | 94 +++---- test/addHeaderFile.js | 47 ++-- test/addRemovePbxGroup.js | 59 ++--- test/addResourceFile.js | 120 ++++----- test/addSourceFile.js | 81 +++--- test/addStaticLibrary.js | 91 ++++--- test/addTarget.js | 50 ++-- test/addTargetDependency.js | 91 +++---- test/addToPbxFileReferenceSection.js | 11 +- test/addWatch2App.js | 36 +-- test/addWatch2Extension.js | 36 +-- test/addWatchApp.js | 36 +-- test/addWatchExtension.js | 36 +-- test/addXCConfigurationList.js | 109 ++++---- test/dataModelDocument.js | 71 +++--- test/group.js | 9 +- test/knownRegions.js | 9 +- test/multipleTargets.js | 11 +- test/parser/build-config.js | 27 +- test/parser/comments.js | 11 +- test/parser/dotsInNames.js | 19 +- test/parser/file-references.js | 15 +- test/parser/hash.js | 15 +- test/parser/header-search.js | 21 +- test/parser/section-entries.js | 15 +- test/parser/section-split.js | 15 +- test/parser/section.js | 15 +- test/parser/two-sections.js | 15 +- test/parser/with_array.js | 15 +- test/pbxFile.js | 4 +- test/pbxItemByComment.js | 9 +- test/pbxProject.js | 63 ++--- test/pbxTargetByName.js | 9 +- test/pbxWriter.js | 17 +- test/removeFramework.js | 74 +++--- test/removeHeaderFile.js | 55 +++-- test/removeResourceFile.js | 99 ++++---- test/removeSourceFile.js | 67 ++--- test/variantGroup.js | 7 +- test/xcode5searchPaths.js | 25 +- 50 files changed, 1177 insertions(+), 1053 deletions(-) diff --git a/lib/parseJob.js b/lib/parseJob.js index 4e34eb2..e3d9260 100644 --- a/lib/parseJob.js +++ b/lib/parseJob.js @@ -17,10 +17,12 @@ // parsing is slow and blocking right now // so we do it in a separate process -var fs = require('fs'), - parser = require('./parser/pbxproj'), - path = process.argv[2], - fileContents, obj; +var fs = require('fs'); + +var parser = require('./parser/pbxproj'); +var path = process.argv[2]; +var fileContents; +var obj; try { fileContents = fs.readFileSync(path, 'utf-8'); diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 9553bfb..79d173b 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -15,14 +15,14 @@ under the License. */ -var path = require('path'), - util = require('util'); +var path = require('path'); -var DEFAULT_SOURCETREE = '""', - DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR', - DEFAULT_FILEENCODING = 4, - DEFAULT_GROUP = 'Resources', - DEFAULT_FILETYPE = 'unknown'; +var util = require('util'); +var DEFAULT_SOURCETREE = '""'; +var DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR'; +var DEFAULT_FILEENCODING = 4; +var DEFAULT_GROUP = 'Resources'; +var DEFAULT_FILETYPE = 'unknown'; var FILETYPE_BY_EXTENSION = { a: 'archive.ar', @@ -48,47 +48,51 @@ var FILETYPE_BY_EXTENSION = { xctest: 'wrapper.cfbundle', xib: 'file.xib', strings: 'text.plist.strings' - }, - GROUP_BY_FILETYPE = { - 'archive.ar': 'Frameworks', - 'compiled.mach-o.dylib': 'Frameworks', - 'sourcecode.text-based-dylib-definition': 'Frameworks', - 'wrapper.framework': 'Frameworks', - 'embedded.framework': 'Embed Frameworks', - 'sourcecode.c.h': 'Resources', - 'sourcecode.c.objc': 'Sources', - 'sourcecode.swift': 'Sources' - }, - PATH_BY_FILETYPE = { - 'compiled.mach-o.dylib': 'usr/lib/', - 'sourcecode.text-based-dylib-definition': 'usr/lib/', - 'wrapper.framework': 'System/Library/Frameworks/' - }, - SOURCETREE_BY_FILETYPE = { - 'compiled.mach-o.dylib': 'SDKROOT', - 'sourcecode.text-based-dylib-definition': 'SDKROOT', - 'wrapper.framework': 'SDKROOT' - }, - ENCODING_BY_FILETYPE = { - 'sourcecode.c.h': 4, - 'sourcecode.c.h': 4, - 'sourcecode.c.objc': 4, - 'sourcecode.swift': 4, - 'text': 4, - 'text.plist.xml': 4, - 'text.script.sh': 4, - 'text.xcconfig': 4, - 'text.plist.strings': 4 }; +var GROUP_BY_FILETYPE = { + 'archive.ar': 'Frameworks', + 'compiled.mach-o.dylib': 'Frameworks', + 'sourcecode.text-based-dylib-definition': 'Frameworks', + 'wrapper.framework': 'Frameworks', + 'embedded.framework': 'Embed Frameworks', + 'sourcecode.c.h': 'Resources', + 'sourcecode.c.objc': 'Sources', + 'sourcecode.swift': 'Sources' +}; + +var PATH_BY_FILETYPE = { + 'compiled.mach-o.dylib': 'usr/lib/', + 'sourcecode.text-based-dylib-definition': 'usr/lib/', + 'wrapper.framework': 'System/Library/Frameworks/' +}; + +var SOURCETREE_BY_FILETYPE = { + 'compiled.mach-o.dylib': 'SDKROOT', + 'sourcecode.text-based-dylib-definition': 'SDKROOT', + 'wrapper.framework': 'SDKROOT' +}; + +var ENCODING_BY_FILETYPE = { + 'sourcecode.c.h': 4, + 'sourcecode.c.h': 4, + 'sourcecode.c.objc': 4, + 'sourcecode.swift': 4, + 'text': 4, + 'text.plist.xml': 4, + 'text.script.sh': 4, + 'text.xcconfig': 4, + 'text.plist.strings': 4 +}; + function unquoted(text){ return text == null ? '' : text.replace (/(^")|("$)/g, '') } function detectType(filePath) { - var extension = path.extname(filePath).substring(1), - filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; + var extension = path.extname(filePath).substring(1); + var filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; if (!filetype) { return DEFAULT_FILETYPE; @@ -110,8 +114,8 @@ function defaultExtension(fileRef) { } function defaultEncoding(fileRef) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + var encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; if (encoding) { return encoding; @@ -119,9 +123,9 @@ function defaultEncoding(fileRef) { } function detectGroup(fileRef, opt) { - var extension = path.extname(fileRef.basename).substring(1), - filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; + var extension = path.extname(fileRef.basename).substring(1); + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + var groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; if (extension === 'xcdatamodeld') { return 'Sources'; @@ -139,9 +143,8 @@ function detectGroup(fileRef, opt) { } function detectSourcetree(fileRef) { - - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + var sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; if (fileRef.explicitFileType) { return DEFAULT_PRODUCT_SOURCETREE; @@ -159,8 +162,8 @@ function detectSourcetree(fileRef) { } function defaultPath(fileRef, filePath) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + var defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; if (fileRef.customFramework) { return filePath; diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 3097678..4833913 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -15,18 +15,19 @@ under the License. */ -var util = require('util'), - f = util.format, - EventEmitter = require('events').EventEmitter, - path = require('path'), - uuid = require('uuid'), - fork = require('child_process').fork, - pbxWriter = require('./pbxWriter'), - pbxFile = require('./pbxFile'), - fs = require('fs'), - parser = require('./parser/pbxproj'), - plist = require('simple-plist'), - COMMENT_KEY = /_comment$/ +var util = require('util'); + +var f = util.format; +var EventEmitter = require('events').EventEmitter; +var path = require('path'); +var uuid = require('uuid'); +var fork = require('child_process').fork; +var pbxWriter = require('./pbxWriter'); +var pbxFile = require('./pbxFile'); +var fs = require('fs'); +var parser = require('./parser/pbxproj'); +var plist = require('simple-plist'); +var COMMENT_KEY = /_comment$/; function pbxProject(filename) { if (!(this instanceof pbxProject)) @@ -70,9 +71,9 @@ pbxProject.prototype.writeSync = function(options) { } pbxProject.prototype.allUuids = function() { - var sections = this.hash.project.objects, - uuids = [], - section; + var sections = this.hash.project.objects; + var uuids = []; + var section; for (key in sections) { section = sections[key] @@ -492,32 +493,34 @@ pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { } pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTree) { - var groups = this.hash.project.objects['PBXGroup'], - pbxGroupUuid = this.generateUuid(), - commentKey = f("%s_comment", pbxGroupUuid), - pbxGroup = { - isa: 'PBXGroup', - children: [], - name: name, - path: path, - sourceTree: sourceTree ? sourceTree : '""' - }, - fileReferenceSection = this.pbxFileReferenceSection(), - filePathToReference = {}; + var groups = this.hash.project.objects['PBXGroup']; + var pbxGroupUuid = this.generateUuid(); + var commentKey = f("%s_comment", pbxGroupUuid); + + var pbxGroup = { + isa: 'PBXGroup', + children: [], + name: name, + path: path, + sourceTree: sourceTree ? sourceTree : '""' + }; + + var fileReferenceSection = this.pbxFileReferenceSection(); + var filePathToReference = {}; for (var key in fileReferenceSection) { // only look for comments if (!COMMENT_KEY.test(key)) continue; - var fileReferenceKey = key.split(COMMENT_KEY)[0], - fileReference = fileReferenceSection[fileReferenceKey]; + var fileReferenceKey = key.split(COMMENT_KEY)[0]; + var fileReference = fileReferenceSection[fileReferenceKey]; filePathToReference[fileReference.path] = { fileRef: fileReferenceKey, basename: fileReferenceSection[key] }; } for (var index = 0; index < filePathsArray.length; index++) { - var filePath = filePathsArray[index], - filePathQuoted = "\"" + filePath + "\""; + var filePath = filePathsArray[index]; + var filePathQuoted = "\"" + filePath + "\""; if (filePathToReference[filePath]) { pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath])); continue; @@ -543,8 +546,9 @@ pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTr } pbxProject.prototype.removePbxGroup = function (groupName) { - var section = this.hash.project.objects['PBXGroup'], - key, itemKey; + var section = this.hash.project.objects['PBXGroup']; + var key; + var itemKey; for (key in section) { // only look for comments @@ -637,7 +641,8 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function(file) { if (!this.pbxGroupByName('Plugins')) { return null; } - var pluginsGroupChildren = this.pbxGroupByName('Plugins').children, i; + var pluginsGroupChildren = this.pbxGroupByName('Plugins').children; + var i; for (i in pluginsGroupChildren) { if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { @@ -660,7 +665,8 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function(file) { if (!this.pbxGroupByName('Resources')) { return null; } - var pluginsGroupChildren = this.pbxGroupByName('Resources').children, i; + var pluginsGroupChildren = this.pbxGroupByName('Resources').children; + var i; for (i in pluginsGroupChildren) { if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { @@ -727,7 +733,8 @@ pbxProject.prototype.removeFromProductsPbxGroup = function(file) { if (!this.pbxGroupByName('Products')) { return null; } - var productsGroupChildren = this.pbxGroupByName('Products').children, i; + var productsGroupChildren = this.pbxGroupByName('Products').children; + var i; for (i in productsGroupChildren) { if (pbxGroupChild(file).value == productsGroupChildren[i].value && pbxGroupChild(file).comment == productsGroupChildren[i].comment) { @@ -743,8 +750,8 @@ pbxProject.prototype.addToPbxSourcesBuildPhase = function(file) { } pbxProject.prototype.removeFromPbxSourcesBuildPhase = function(file) { - - var sources = this.pbxSourcesBuildPhaseObj(file.target), i; + var sources = this.pbxSourcesBuildPhaseObj(file.target); + var i; for (i in sources.files) { if (sources.files[i].comment == longComment(file)) { sources.files.splice(i, 1); @@ -759,7 +766,8 @@ pbxProject.prototype.addToPbxResourcesBuildPhase = function(file) { } pbxProject.prototype.removeFromPbxResourcesBuildPhase = function(file) { - var sources = this.pbxResourcesBuildPhaseObj(file.target), i; + var sources = this.pbxResourcesBuildPhaseObj(file.target); + var i; for (i in sources.files) { if (sources.files[i].comment == longComment(file)) { @@ -785,21 +793,22 @@ pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) { } pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray, defaultConfigurationName, comment) { - var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(), - pbxXCConfigurationListSection = this.pbxXCConfigurationList(), - xcConfigurationListUuid = this.generateUuid(), - commentKey = f("%s_comment", xcConfigurationListUuid), - xcConfigurationList = { - isa: 'XCConfigurationList', - buildConfigurations: [], - defaultConfigurationIsVisible: 0, - defaultConfigurationName: defaultConfigurationName - }; + var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(); + var pbxXCConfigurationListSection = this.pbxXCConfigurationList(); + var xcConfigurationListUuid = this.generateUuid(); + var commentKey = f("%s_comment", xcConfigurationListUuid); + + var xcConfigurationList = { + isa: 'XCConfigurationList', + buildConfigurations: [], + defaultConfigurationIsVisible: 0, + defaultConfigurationName: defaultConfigurationName + }; for (var index = 0; index < configurationObjectsArray.length; index++) { - var configuration = configurationObjectsArray[index], - configurationUuid = this.generateUuid(), - configurationCommentKey = f("%s_comment", configurationUuid); + var configuration = configurationObjectsArray[index]; + var configurationUuid = this.generateUuid(); + var configurationCommentKey = f("%s_comment", configurationUuid); pbxBuildConfigurationSection[configurationUuid] = configuration; pbxBuildConfigurationSection[configurationCommentKey] = configuration.name; @@ -829,33 +838,35 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { throw new Error("Invalid target: " + dependencyTarget); } - var pbxTargetDependency = 'PBXTargetDependency', - pbxContainerItemProxy = 'PBXContainerItemProxy', - pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency], - pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; + var pbxTargetDependency = 'PBXTargetDependency'; + var pbxContainerItemProxy = 'PBXContainerItemProxy'; + var pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency]; + var pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; for (var index = 0; index < dependencyTargets.length; index++) { - var dependencyTargetUuid = dependencyTargets[index], - dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid), - targetDependencyUuid = this.generateUuid(), - targetDependencyCommentKey = f("%s_comment", targetDependencyUuid), - itemProxyUuid = this.generateUuid(), - itemProxyCommentKey = f("%s_comment", itemProxyUuid), - itemProxy = { - isa: pbxContainerItemProxy, - containerPortal: this.hash.project['rootObject'], - containerPortal_comment: this.hash.project['rootObject_comment'], - proxyType: 1, - remoteGlobalIDString: dependencyTargetUuid, - remoteInfo: nativeTargets[dependencyTargetUuid].name - }, - targetDependency = { - isa: pbxTargetDependency, - target: dependencyTargetUuid, - target_comment: nativeTargets[dependencyTargetCommentKey], - targetProxy: itemProxyUuid, - targetProxy_comment: pbxContainerItemProxy - }; + var dependencyTargetUuid = dependencyTargets[index]; + var dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid); + var targetDependencyUuid = this.generateUuid(); + var targetDependencyCommentKey = f("%s_comment", targetDependencyUuid); + var itemProxyUuid = this.generateUuid(); + var itemProxyCommentKey = f("%s_comment", itemProxyUuid); + + var itemProxy = { + isa: pbxContainerItemProxy, + containerPortal: this.hash.project['rootObject'], + containerPortal_comment: this.hash.project['rootObject_comment'], + proxyType: 1, + remoteGlobalIDString: dependencyTargetUuid, + remoteInfo: nativeTargets[dependencyTargetUuid].name + }; + + var targetDependency = { + isa: pbxTargetDependency, + target: dependencyTargetUuid, + target_comment: nativeTargets[dependencyTargetCommentKey], + targetProxy: itemProxyUuid, + targetProxy_comment: pbxContainerItemProxy + }; if (pbxContainerItemProxySection && pbxTargetDependencySection) { pbxContainerItemProxySection[itemProxyUuid] = itemProxy; @@ -870,19 +881,21 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { } pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) { - var buildPhaseSection, - fileReferenceSection = this.pbxFileReferenceSection(), - buildFileSection = this.pbxBuildFileSection(), - buildPhaseUuid = this.generateUuid(), - buildPhaseTargetUuid = target || this.getFirstTarget().uuid, - commentKey = f("%s_comment", buildPhaseUuid), - buildPhase = { - isa: buildPhaseType, - buildActionMask: 2147483647, - files: [], - runOnlyForDeploymentPostprocessing: 0 - }, - filePathToBuildFile = {}; + var buildPhaseSection; + var fileReferenceSection = this.pbxFileReferenceSection(); + var buildFileSection = this.pbxBuildFileSection(); + var buildPhaseUuid = this.generateUuid(); + var buildPhaseTargetUuid = target || this.getFirstTarget().uuid; + var commentKey = f("%s_comment", buildPhaseUuid); + + var buildPhase = { + isa: buildPhaseType, + buildActionMask: 2147483647, + files: [], + runOnlyForDeploymentPostprocessing: 0 + }; + + var filePathToBuildFile = {}; if (buildPhaseType === 'PBXCopyFilesBuildPhase') { buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment); @@ -912,8 +925,8 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co // only look for comments if (!COMMENT_KEY.test(key)) continue; - var buildFileKey = key.split(COMMENT_KEY)[0], - buildFile = buildFileSection[buildFileKey]; + var buildFileKey = key.split(COMMENT_KEY)[0]; + var buildFile = buildFileSection[buildFileKey]; fileReference = fileReferenceSection[buildFile.fileRef]; if (!fileReference) continue; @@ -924,9 +937,9 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co } for (var index = 0; index < filePathsArray.length; index++) { - var filePath = filePathsArray[index], - filePathQuoted = "\"" + filePath + "\"", - file = new pbxFile(filePath); + var filePath = filePathsArray[index]; + var filePathQuoted = "\"" + filePath + "\""; + var file = new pbxFile(filePath); if (filePathToBuildFile[filePath]) { buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePath])); @@ -984,8 +997,9 @@ pbxProject.prototype.pbxXCConfigurationList = function() { } pbxProject.prototype.pbxGroupByName = function(name) { - var groups = this.hash.project.objects['PBXGroup'], - key, groupKey; + var groups = this.hash.project.objects['PBXGroup']; + var key; + var groupKey; for (key in groups) { // only look for comments @@ -1021,8 +1035,9 @@ pbxProject.prototype.findTargetKey = function(name) { } pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) { - var section = this.hash.project.objects[pbxSectionName], - key, itemKey; + var section = this.hash.project.objects[pbxSectionName]; + var key; + var itemKey; for (key in section) { // only look for comments @@ -1074,8 +1089,10 @@ pbxProject.prototype.buildPhase = function(group, target) { } pbxProject.prototype.buildPhaseObject = function(name, group, target) { - var section = this.hash.project.objects[name], - obj, sectionKey, key; + var section = this.hash.project.objects[name]; + var obj; + var sectionKey; + var key; var buildPhase = this.buildPhase(group, target); for (key in section) { @@ -1095,8 +1112,9 @@ pbxProject.prototype.buildPhaseObject = function(name, group, target) { } pbxProject.prototype.addBuildProperty = function(prop, value, build_name) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - key, configuration; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var key; + var configuration; for (key in configurations){ configuration = configurations[key]; @@ -1107,8 +1125,9 @@ pbxProject.prototype.addBuildProperty = function(prop, value, build_name) { } pbxProject.prototype.removeBuildProperty = function(prop, build_name) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - key, configuration; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var key; + var configuration; for (key in configurations){ configuration = configurations[key]; @@ -1142,10 +1161,12 @@ pbxProject.prototype.updateProductName = function(name) { } pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS', - config, buildSettings, searchPaths; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS'; + var config; + var buildSettings; + var searchPaths; var new_path = searchPathForFile(file, this); for (config in configurations) { @@ -1169,9 +1190,11 @@ pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) { } pbxProject.prototype.addToFrameworkSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - config, buildSettings, searchPaths; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var config; + var buildSettings; + var searchPaths; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1189,10 +1212,12 @@ pbxProject.prototype.addToFrameworkSearchPaths = function(file) { } pbxProject.prototype.removeFromLibrarySearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS', - config, buildSettings, searchPaths; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS'; + var config; + var buildSettings; + var searchPaths; var new_path = searchPathForFile(file, this); for (config in configurations) { @@ -1217,9 +1242,11 @@ pbxProject.prototype.removeFromLibrarySearchPaths = function(file) { } pbxProject.prototype.addToLibrarySearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - config, buildSettings, searchPaths; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var config; + var buildSettings; + var searchPaths; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1241,10 +1268,12 @@ pbxProject.prototype.addToLibrarySearchPaths = function(file) { } pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - SEARCH_PATHS = 'HEADER_SEARCH_PATHS', - config, buildSettings, searchPaths; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var SEARCH_PATHS = 'HEADER_SEARCH_PATHS'; + var config; + var buildSettings; + var searchPaths; var new_path = searchPathForFile(file, this); for (config in configurations) { @@ -1266,9 +1295,11 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { } } pbxProject.prototype.addToHeaderSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - config, buildSettings, searchPaths; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var config; + var buildSettings; + var searchPaths; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1289,10 +1320,11 @@ pbxProject.prototype.addToHeaderSearchPaths = function(file) { } pbxProject.prototype.addToOtherLinkerFlags = function (flag) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - OTHER_LDFLAGS = 'OTHER_LDFLAGS', - config, buildSettings; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var INHERITED = '"$(inherited)"'; + var OTHER_LDFLAGS = 'OTHER_LDFLAGS'; + var config; + var buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1310,9 +1342,10 @@ pbxProject.prototype.addToOtherLinkerFlags = function (flag) { } pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - OTHER_LDFLAGS = 'OTHER_LDFLAGS', - config, buildSettings; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var OTHER_LDFLAGS = 'OTHER_LDFLAGS'; + var config; + var buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1334,8 +1367,9 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { } pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - config, buildSettings; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var config; + var buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1345,8 +1379,9 @@ pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { } pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - config, buildSettings; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var config; + var buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1359,8 +1394,9 @@ pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { // a JS getter. hmmm pbxProject.prototype.__defineGetter__("productName", function() { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - config, productName; + var configurations = nonComments(this.pbxXCBuildConfigurationSection()); + var config; + var productName; for (config in configurations) { productName = configurations[config].buildSettings['PRODUCT_NAME']; @@ -1373,8 +1409,9 @@ pbxProject.prototype.__defineGetter__("productName", function() { // check if file is present pbxProject.prototype.hasFile = function(filePath) { - var files = nonComments(this.pbxFileReferenceSection()), - file, id; + var files = nonComments(this.pbxFileReferenceSection()); + var file; + var id; for (id in files) { file = files[id]; if (file.path == filePath || file.path == ('"' + filePath + '"')) { @@ -1386,12 +1423,12 @@ pbxProject.prototype.hasFile = function(filePath) { } pbxProject.prototype.addTarget = function(name, type, subfolder) { - // Setup uuid and name of new target - var targetUuid = this.generateUuid(), - targetType = type, - targetSubfolder = subfolder || name, - targetName = name.trim(); + var targetUuid = this.generateUuid(); + + var targetType = type; + var targetSubfolder = subfolder || name; + var targetName = name.trim(); // Check type against list of allowed target types if (!targetName) { @@ -1437,11 +1474,12 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"'); // Product: Create - var productName = targetName, - productType = producttypeForTargettype(targetType), - productFileType = filetypeForProducttype(productType), - productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}), - productFileName = productFile.basename; + var productName = targetName; + + var productType = producttypeForTargettype(targetType); + var productFileType = filetypeForProducttype(productType); + var productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}); + var productFileName = productFile.basename; // Product: Add to build file list @@ -1516,7 +1554,6 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { // Return target on success return target; - }; // helper object creation functions @@ -1652,9 +1689,9 @@ function correctForPath(file, project, group) { } function searchPathForFile(file, proj) { - var plugins = proj.pbxGroupByName('Plugins'), - pluginsPath = plugins ? plugins.path : null, - fileDir = path.dirname(file.path); + var plugins = proj.pbxGroupByName('Plugins'); + var pluginsPath = plugins ? plugins.path : null; + var fileDir = path.dirname(file.path); if (fileDir == '.') { fileDir = ''; @@ -1672,8 +1709,9 @@ function searchPathForFile(file, proj) { } function nonComments(obj) { - var keys = Object.keys(obj), - newObj = {}, i = 0; + var keys = Object.keys(obj); + var newObj = {}; + var i = 0; for (i; i < keys.length; i++) { if (!COMMENT_KEY.test(keys[i])) { @@ -1865,7 +1903,8 @@ pbxProject.prototype.pbxCreateGroup = function(name, pathName) { pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, groupType) { var group = this.getPBXGroupByKeyAndType(groupKey, groupType); if (group) { - var groupChildren = group.children, i; + var groupChildren = group.children; + var i; for(i in groupChildren) { if(pbxGroupChild(file).value == groupChildren[i].value && pbxGroupChild(file).comment == groupChildren[i].comment) { diff --git a/lib/pbxWriter.js b/lib/pbxWriter.js index d297bc7..4ccfc51 100644 --- a/lib/pbxWriter.js +++ b/lib/pbxWriter.js @@ -15,13 +15,14 @@ under the License. */ -var pbxProj = require('./pbxProject'), - util = require('util'), - f = util.format, - INDENT = '\t', - COMMENT_KEY = /_comment$/, - QUOTED = /^"(.*)"$/, - EventEmitter = require('events').EventEmitter +var pbxProj = require('./pbxProject'); + +var util = require('util'); +var f = util.format; +var INDENT = '\t'; +var COMMENT_KEY = /_comment$/; +var QUOTED = /^"(.*)"$/; +var EventEmitter = require('events').EventEmitter; // indentation function i(x) { @@ -102,8 +103,10 @@ pbxWriter.prototype.writeHeadComment = function () { } pbxWriter.prototype.writeProject = function () { - var proj = this.contents.project, - key, cmt, obj; + var proj = this.contents.project; + var key; + var cmt; + var obj; this.write("{\n") @@ -147,7 +150,9 @@ pbxWriter.prototype.writeProject = function () { } pbxWriter.prototype.writeObject = function (object) { - var key, obj, cmt; + var key; + var obj; + var cmt; for (key in object) { if (COMMENT_KEY.test(key)) continue; @@ -178,7 +183,8 @@ pbxWriter.prototype.writeObject = function (object) { } pbxWriter.prototype.writeObjectsSections = function (objects) { - var key, obj; + var key; + var obj; for (key in objects) { this.writeFlush("\n") @@ -196,7 +202,8 @@ pbxWriter.prototype.writeObjectsSections = function (objects) { } pbxWriter.prototype.writeArray = function (arr, name) { - var i, entry; + var i; + var entry; this.write("%s = (\n", name); this.indentLevel++; @@ -232,7 +239,9 @@ pbxWriter.prototype.writeSectionComment = function (name, begin) { } pbxWriter.prototype.writeSection = function (section) { - var key, obj, cmt; + var key; + var obj; + var cmt; // section should only contain objects for (key in section) { @@ -265,7 +274,9 @@ pbxWriter.prototype.writeInlineObject = function (n, d, r) { var self = this var inlineObjectHelper = function (name, desc, ref) { - var key, cmt, obj; + var key; + var cmt; + var obj; if (desc) { output.push(f("%s /* %s */ = {", name, desc)); diff --git a/test/BuildSettings.js b/test/BuildSettings.js index 213f575..84bfd49 100644 --- a/test/BuildSettings.js +++ b/test/BuildSettings.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/FrameworkSearchPaths.js b/test/FrameworkSearchPaths.js index b709f3a..a6b30e0 100644 --- a/test/FrameworkSearchPaths.js +++ b/test/FrameworkSearchPaths.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); var pbxFile = { path:'some/path/include', diff --git a/test/HeaderSearchPaths.js b/test/HeaderSearchPaths.js index 998fd8b..5b76616 100644 --- a/test/HeaderSearchPaths.js +++ b/test/HeaderSearchPaths.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/LibrarySearchPaths.js b/test/LibrarySearchPaths.js index 6788e10..0fcfbe9 100644 --- a/test/LibrarySearchPaths.js +++ b/test/LibrarySearchPaths.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/OtherLinkerFlags.js b/test/OtherLinkerFlags.js index de59f4c..2a4225c 100644 --- a/test/OtherLinkerFlags.js +++ b/test/OtherLinkerFlags.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index eb105f8..e694344 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -15,10 +15,11 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -52,8 +53,8 @@ exports.addBuildPhase = { test.done() }, 'should add the PBXBuildPhase object correctly': function (test) { - var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase, - buildPhaseInPbx = proj.buildPhaseObject('PBXResourcesBuildPhase', 'My build phase'); + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var buildPhaseInPbx = proj.buildPhaseObject('PBXResourcesBuildPhase', 'My build phase'); test.equal(buildPhaseInPbx, buildPhase); test.equal(buildPhaseInPbx.isa, 'PBXResourcesBuildPhase'); @@ -62,8 +63,8 @@ exports.addBuildPhase = { test.done(); }, 'should add each of the files to PBXBuildFile section': function (test) { - var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase, - buildFileSection = proj.pbxBuildFileSection(); + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var buildFileSection = proj.pbxBuildFileSection(); for (var index = 0; index < buildPhase.files.length; index++) { var file = buildPhase.files[index]; @@ -73,14 +74,14 @@ exports.addBuildPhase = { test.done(); }, 'should add each of the files to PBXFileReference section': function (test) { - var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase, - fileRefSection = proj.pbxFileReferenceSection(), - buildFileSection = proj.pbxBuildFileSection(), - fileRefs = []; + var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var fileRefSection = proj.pbxFileReferenceSection(); + var buildFileSection = proj.pbxBuildFileSection(); + var fileRefs = []; for (var index = 0; index < buildPhase.files.length; index++) { - var file = buildPhase.files[index], - fileRef = buildFileSection[file.value].fileRef; + var file = buildPhase.files[index]; + var fileRef = buildFileSection[file.value].fileRef; test.ok(fileRefSection[fileRef]); } @@ -88,33 +89,33 @@ exports.addBuildPhase = { test.done(); }, 'should not add files to PBXFileReference section if already added': function (test) { - var fileRefSection = proj.pbxFileReferenceSection(), - initialFileReferenceSectionItemsCount = Object.keys(fileRefSection), - buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase, - afterAdditionBuildFileSectionItemsCount = Object.keys(fileRefSection); + var fileRefSection = proj.pbxFileReferenceSection(); + var initialFileReferenceSectionItemsCount = Object.keys(fileRefSection); + var buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var afterAdditionBuildFileSectionItemsCount = Object.keys(fileRefSection); test.deepEqual(initialFileReferenceSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); }, 'should not add files to PBXBuildFile section if already added': function (test) { - var buildFileSection = proj.pbxBuildFileSection(), - initialBuildFileSectionItemsCount = Object.keys(buildFileSection), - buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase, - afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); + var buildFileSection = proj.pbxBuildFileSection(); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); }, 'should add only missing files to PBXFileReference section': function (test) { - var fileRefSection = proj.pbxFileReferenceSection(), - buildFileSection = proj.pbxBuildFileSection(), - initialFileReferenceSectionItemsCount = Object.keys(fileRefSection), - buildPhase = proj.addBuildPhase(['file.m', 'AppDelegate.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase, - afterAdditionBuildFileSectionItemsCount = Object.keys(fileRefSection); + var fileRefSection = proj.pbxFileReferenceSection(); + var buildFileSection = proj.pbxBuildFileSection(); + var initialFileReferenceSectionItemsCount = Object.keys(fileRefSection); + var buildPhase = proj.addBuildPhase(['file.m', 'AppDelegate.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var afterAdditionBuildFileSectionItemsCount = Object.keys(fileRefSection); for (var index = 0; index < buildPhase.files.length; index++) { - var file = buildPhase.files[index], - fileRef = buildFileSection[file.value].fileRef; + var file = buildPhase.files[index]; + var fileRef = buildFileSection[file.value].fileRef; test.ok(fileRefSection[fileRef]); } diff --git a/test/addFramework.js b/test/addFramework.js index c3c3200..de28b9e 100644 --- a/test/addFramework.js +++ b/test/addFramework.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -31,8 +32,9 @@ exports.setUp = function (callback) { } function nonComments(obj) { - var keys = Object.keys(obj), - newObj = {}, i = 0; + var keys = Object.keys(obj); + var newObj = {}; + var i = 0; for (i; i < keys.length; i++) { if (!/_comment$/.test(keys[i])) { @@ -44,9 +46,11 @@ function nonComments(obj) { } function frameworkSearchPaths(proj) { - var configs = nonComments(proj.pbxXCBuildConfigurationSection()), - allPaths = [], - ids = Object.keys(configs), i, buildSettings; + var configs = nonComments(proj.pbxXCBuildConfigurationSection()); + var allPaths = []; + var ids = Object.keys(configs); + var i; + var buildSettings; for (i = 0; i< ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; @@ -92,9 +96,9 @@ exports.addFramework = { test.done(); }, 'should add the PBXFileReference object correctly': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addFramework('libsqlite3.dylib'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.lastKnownFileType, 'compiled.mach-o.dylib'); @@ -105,9 +109,9 @@ exports.addFramework = { test.done(); }, 'should populate the PBXBuildFile section with 2 fields': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addFramework('libsqlite3.dylib'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -116,17 +120,17 @@ exports.addFramework = { test.done(); }, 'should add the PBXBuildFile comment correctly': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var newFile = proj.addFramework('libsqlite3.dylib'); + var commentKey = newFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.equal(buildFileSection[commentKey], 'libsqlite3.dylib in Frameworks'); test.done(); }, 'should add the PBXBuildFile object correctly': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.addFramework('libsqlite3.dylib'); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); @@ -136,9 +140,9 @@ exports.addFramework = { test.done(); }, 'should add the PBXBuildFile object correctly /w weak linked frameworks': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib', { weak: true }), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.addFramework('libsqlite3.dylib', { weak: true }); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); @@ -148,40 +152,40 @@ exports.addFramework = { test.done(); }, 'should add to the Frameworks PBXGroup': function (test) { - var newLength = proj.pbxGroupByName('Frameworks').children.length + 1, - newFile = proj.addFramework('libsqlite3.dylib'), - frameworks = proj.pbxGroupByName('Frameworks'); + var newLength = proj.pbxGroupByName('Frameworks').children.length + 1; + var newFile = proj.addFramework('libsqlite3.dylib'); + var frameworks = proj.pbxGroupByName('Frameworks'); test.equal(frameworks.children.length, newLength); test.done(); }, 'should have the right values for the PBXGroup entry': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - frameworks = proj.pbxGroupByName('Frameworks').children, - framework = frameworks[frameworks.length - 1]; + var newFile = proj.addFramework('libsqlite3.dylib'); + var frameworks = proj.pbxGroupByName('Frameworks').children; + var framework = frameworks[frameworks.length - 1]; test.equal(framework.comment, 'libsqlite3.dylib'); test.equal(framework.value, newFile.fileRef); test.done(); }, 'should add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var newFile = proj.addFramework('libsqlite3.dylib'); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); test.done(); }, 'should not add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('Private.framework', {link: false}), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var newFile = proj.addFramework('Private.framework', {link: false}); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); test.done(); }, 'should have the right values for the Sources entry': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - frameworks = proj.pbxFrameworksBuildPhaseObj(), - framework = frameworks.files[15]; + var newFile = proj.addFramework('libsqlite3.dylib'); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); + var framework = frameworks.files[15]; test.equal(framework.comment, 'libsqlite3.dylib in Frameworks'); test.equal(framework.value, newFile.uuid); @@ -220,8 +224,8 @@ exports.addFramework = { test.done(); }, 'should add to the Embed Frameworks PBXCopyFilesBuildPhase': function (test) { - var newFile = proj.addFramework('/path/to/SomeEmbeddableCustom.framework', {customFramework: true, embed: true}), - frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); + var newFile = proj.addFramework('/path/to/SomeEmbeddableCustom.framework', {customFramework: true, embed: true}); + var frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); var buildPhaseInPbx = proj.pbxEmbedFrameworksBuildPhaseObj(); test.equal(buildPhaseInPbx.dstSubfolderSpec, 10); @@ -230,16 +234,16 @@ exports.addFramework = { test.done(); }, 'should not add to the Embed Frameworks PBXCopyFilesBuildPhase by default': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', {customFramework: true}), - frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); + var newFile = proj.addFramework('/path/to/Custom.framework', {customFramework: true}); + var frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 0); test.done(); }, 'should add the PBXBuildFile object correctly /w signable frameworks': function (test) { - var newFile = proj.addFramework('/path/to/SomeSignable.framework', { customFramework: true, embed: true, sign: true }), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.addFramework('/path/to/SomeSignable.framework', { customFramework: true, embed: true, sign: true }); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(newFile.group, 'Embed Frameworks'); test.equal(buildFileEntry.isa, 'PBXBuildFile'); diff --git a/test/addHeaderFile.js b/test/addHeaderFile.js index f9bd71a..4b71ba2 100644 --- a/test/addHeaderFile.js +++ b/test/addHeaderFile.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -44,9 +45,9 @@ exports.addHeaderFile = { test.done() }, 'should populate the PBXFileReference section with 2 fields': function (test) { - var newFile = proj.addHeaderFile('file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addHeaderFile('file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -55,17 +56,17 @@ exports.addHeaderFile = { test.done(); }, 'should populate the PBXFileReference comment correctly': function (test) { - var newFile = proj.addHeaderFile('file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.addHeaderFile('file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'file.h'); test.done(); }, 'should add the PBXFileReference object correctly': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addHeaderFile('Plugins/file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.fileEncoding, 4); @@ -77,16 +78,16 @@ exports.addHeaderFile = { test.done(); }, 'should add to the Plugins PBXGroup group': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'), - plugins = proj.pbxGroupByName('Plugins'); + var newFile = proj.addHeaderFile('Plugins/file.h'); + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); test.done(); }, 'should have the right values for the PBXGroup entry': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'), - plugins = proj.pbxGroupByName('Plugins'), - pluginObj = plugins.children[0]; + var newFile = proj.addHeaderFile('Plugins/file.h'); + var plugins = proj.pbxGroupByName('Plugins'); + var pluginObj = plugins.children[0]; test.equal(pluginObj.comment, 'file.h'); test.equal(pluginObj.value, newFile.fileRef); @@ -100,10 +101,10 @@ exports.addHeaderFile = { test.done(); }, 'should not add another entry anywhere': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length, - plugins = proj.pbxGroupByName('Plugins'); + var newFile = proj.addHeaderFile('Plugins/file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; + var plugins = proj.pbxGroupByName('Plugins'); proj.addHeaderFile('Plugins/file.h'); diff --git a/test/addRemovePbxGroup.js b/test/addRemovePbxGroup.js index 8212f91..9926084 100644 --- a/test/addRemovePbxGroup.js +++ b/test/addRemovePbxGroup.js @@ -15,10 +15,11 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -75,28 +76,28 @@ exports.addRemovePbxGroup = { test.notEqual(buildFileSection[key].fileRef_comment, 'assets.bundle'); } - var initialBuildFileSectionItemsCount = Object.keys(buildFileSection), - pbxGroup = proj.addPbxGroup(['file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var pbxGroup = proj.addPbxGroup(['file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); // for each file added in the build file section two keyes are added - one for the object and one for the comment test.equal(initialBuildFileSectionItemsCount.length, afterAdditionBuildFileSectionItemsCount.length - 4); test.done(); }, 'should not add any of the files to PBXBuildFile section if already added': function (test) { - var buildFileSection = proj.pbxBuildFileSection(), - initialBuildFileSectionItemsCount = Object.keys(buildFileSection), - pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); + var buildFileSection = proj.pbxBuildFileSection(); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); }, 'should not add any of the files to PBXBuildFile section when they contain special symbols and are already added': function (test) { - var buildFileSection = proj.pbxBuildFileSection(), - initialBuildFileSectionItemsCount = Object.keys(buildFileSection), - pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); + var buildFileSection = proj.pbxBuildFileSection(); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); @@ -108,9 +109,9 @@ exports.addRemovePbxGroup = { test.notEqual(buildFileSection[key].fileRef_comment, 'assets.bundle'); } - var initialBuildFileSectionItemsCount = Object.keys(buildFileSection), - pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); // for each file added in the build file section two keyes are added - one for the object and one for the comment test.equal(initialBuildFileSectionItemsCount.length, afterAdditionBuildFileSectionItemsCount.length - 4); @@ -131,19 +132,19 @@ exports.addRemovePbxGroup = { test.done(); }, 'should not add any of the files to PBXFileReference section if already added': function (test) { - var fileReference = proj.pbxFileReferenceSection (), - initialBuildFileSectionItemsCount = Object.keys(fileReference), - pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); + var fileReference = proj.pbxFileReferenceSection (); + var initialBuildFileSectionItemsCount = Object.keys(fileReference); + var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); }, 'should not add any of the files to PBXFileReference section when they contain special symbols and are already added': function (test) { - var fileReference = proj.pbxFileReferenceSection (), - initialBuildFileSectionItemsCount = Object.keys(fileReference), - pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); + var fileReference = proj.pbxFileReferenceSection (); + var initialBuildFileSectionItemsCount = Object.keys(fileReference); + var pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); @@ -155,9 +156,9 @@ exports.addRemovePbxGroup = { test.notEqual(fileReference[key].fileRef_comment, 'assets.bundle'); } - var initialBuildFileSectionItemsCount = Object.keys(fileReference), - pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'), - afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); + var initialBuildFileSectionItemsCount = Object.keys(fileReference); + var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); + var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); // for each file added in the file reference section two keyes are added - one for the object and one for the comment test.equal(initialBuildFileSectionItemsCount.length, afterAdditionBuildFileSectionItemsCount.length - 4); diff --git a/test/addResourceFile.js b/test/addResourceFile.js index 36afdb2..4bc14d8 100644 --- a/test/addResourceFile.js +++ b/test/addResourceFile.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -50,9 +51,9 @@ exports.addResourceFile = { test.done() }, 'should populate the PBXBuildFile section with 2 fields': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addResourceFile('assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -61,17 +62,17 @@ exports.addResourceFile = { test.done(); }, 'should add the PBXBuildFile comment correctly': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var newFile = proj.addResourceFile('assets.bundle'); + var commentKey = newFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.equal(buildFileSection[commentKey], 'assets.bundle in Resources'); test.done(); }, 'should add the PBXBuildFile object correctly': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.addResourceFile('assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); @@ -80,9 +81,9 @@ exports.addResourceFile = { test.done(); }, 'should populate the PBXFileReference section with 2 fields': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addResourceFile('assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -91,9 +92,9 @@ exports.addResourceFile = { test.done(); }, 'should populate the PBXFileReference comment correctly': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.addResourceFile('assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'assets.bundle'); test.done(); @@ -101,9 +102,9 @@ exports.addResourceFile = { 'should add the PBXFileReference object correctly': function (test) { delete proj.pbxGroupByName('Resources').path; - var newFile = proj.addResourceFile('Resources/assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.fileEncoding, undefined); @@ -115,40 +116,40 @@ exports.addResourceFile = { test.done(); }, 'should add to the Resources PBXGroup group': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'), - resources = proj.pbxGroupByName('Resources'); + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 10); test.done(); }, 'should have the right values for the PBXGroup entry': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'), - resources = proj.pbxGroupByName('Resources'), - resourceObj = resources.children[9]; + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var resources = proj.pbxGroupByName('Resources'); + var resourceObj = resources.children[9]; test.equal(resourceObj.comment, 'assets.bundle'); test.equal(resourceObj.value, newFile.fileRef); test.done(); }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'), - sources = proj.pbxResourcesBuildPhaseObj(); + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 13); test.done(); }, 'should have the right values for the Sources entry': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'), - sources = proj.pbxResourcesBuildPhaseObj(), - sourceObj = sources.files[12]; + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var sources = proj.pbxResourcesBuildPhaseObj(); + var sourceObj = sources.files[12]; test.equal(sourceObj.comment, 'assets.bundle in Resources'); test.equal(sourceObj.value, newFile.uuid); test.done(); }, 'should remove "Resources/" from path if group path is set': function (test) { - var resources = proj.pbxGroupByName('Resources'), - newFile; + var resources = proj.pbxGroupByName('Resources'); + var newFile; resources.path = '"Test200/Resources"'; newFile = proj.addResourceFile('Resources/assets.bundle'); @@ -162,9 +163,10 @@ exports.addResourceFile = { delete proj.pbxGroupByName('Plugins').path; var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + { plugin: true }); + + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.fileEncoding, undefined); @@ -177,8 +179,9 @@ exports.addResourceFile = { 'should add to the Plugins PBXGroup group': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }), - plugins = proj.pbxGroupByName('Plugins'); + { plugin: true }); + + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); test.done(); @@ -186,9 +189,10 @@ exports.addResourceFile = { 'should have the Plugins values for the PBXGroup entry': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }), - plugins = proj.pbxGroupByName('Plugins'), - pluginObj = plugins.children[0]; + { plugin: true }); + + var plugins = proj.pbxGroupByName('Plugins'); + var pluginObj = plugins.children[0]; test.equal(pluginObj.comment, 'assets.bundle'); test.equal(pluginObj.value, newFile.fileRef); @@ -197,8 +201,9 @@ exports.addResourceFile = { 'should add to the PBXSourcesBuildPhase': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }), - sources = proj.pbxResourcesBuildPhaseObj(); + { plugin: true }); + + var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 13); test.done(); @@ -206,9 +211,10 @@ exports.addResourceFile = { 'should have the right values for the Sources entry': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }), - sources = proj.pbxResourcesBuildPhaseObj(), - sourceObj = sources.files[12]; + { plugin: true }); + + var sources = proj.pbxResourcesBuildPhaseObj(); + var sourceObj = sources.files[12]; test.equal(sourceObj.comment, 'assets.bundle in Resources'); test.equal(sourceObj.value, newFile.uuid); @@ -216,8 +222,8 @@ exports.addResourceFile = { }, 'should remove "Plugins/" from path if group path is set': function (test) { - var plugins = proj.pbxGroupByName('Plugins'), - newFile; + var plugins = proj.pbxGroupByName('Plugins'); + var newFile; plugins.path = '"Test200/Plugins"'; newFile = proj.addResourceFile('Plugins/assets.bundle', @@ -259,13 +265,13 @@ exports.addResourceFile = { test.done(); }, 'should not add another entry anywhere': function (test) { - var newFile = proj.addResourceFile('Plugins/assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length, - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length, - resources = proj.pbxGroupByName('Resources'), - sources = proj.pbxResourcesBuildPhaseObj(); + var newFile = proj.addResourceFile('Plugins/assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; + var resources = proj.pbxGroupByName('Resources'); + var sources = proj.pbxResourcesBuildPhaseObj(); proj.addResourceFile('Plugins/assets.bundle'); diff --git a/test/addSourceFile.js b/test/addSourceFile.js index d614d62..ee005f8 100644 --- a/test/addSourceFile.js +++ b/test/addSourceFile.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -50,9 +51,9 @@ exports.addSourceFile = { test.done() }, 'should populate the PBXBuildFile section with 2 fields': function (test) { - var newFile = proj.addSourceFile('file.m'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addSourceFile('file.m'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -61,17 +62,17 @@ exports.addSourceFile = { test.done(); }, 'should add the PBXBuildFile comment correctly': function (test) { - var newFile = proj.addSourceFile('file.m'), - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var newFile = proj.addSourceFile('file.m'); + var commentKey = newFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.equal(buildFileSection[commentKey], 'file.m in Sources'); test.done(); }, 'should add the PBXBuildFile object correctly': function (test) { - var newFile = proj.addSourceFile('file.m'), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.addSourceFile('file.m'); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); @@ -80,9 +81,9 @@ exports.addSourceFile = { test.done(); }, 'should populate the PBXFileReference section with 2 fields': function (test) { - var newFile = proj.addSourceFile('file.m'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addSourceFile('file.m'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -91,17 +92,17 @@ exports.addSourceFile = { test.done(); }, 'should populate the PBXFileReference comment correctly': function (test) { - var newFile = proj.addSourceFile('file.m'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.addSourceFile('file.m'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'file.m'); test.done(); }, 'should add the PBXFileReference object correctly': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addSourceFile('Plugins/file.m'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.fileEncoding, 4); @@ -113,32 +114,32 @@ exports.addSourceFile = { test.done(); }, 'should add to the Plugins PBXGroup group': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'), - plugins = proj.pbxGroupByName('Plugins'); + var newFile = proj.addSourceFile('Plugins/file.m'); + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); test.done(); }, 'should have the right values for the PBXGroup entry': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'), - plugins = proj.pbxGroupByName('Plugins'), - pluginObj = plugins.children[0]; + var newFile = proj.addSourceFile('Plugins/file.m'); + var plugins = proj.pbxGroupByName('Plugins'); + var pluginObj = plugins.children[0]; test.equal(pluginObj.comment, 'file.m'); test.equal(pluginObj.value, newFile.fileRef); test.done(); }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'), - sources = proj.pbxSourcesBuildPhaseObj(); + var newFile = proj.addSourceFile('Plugins/file.m'); + var sources = proj.pbxSourcesBuildPhaseObj(); test.equal(sources.files.length, 3); test.done(); }, 'should have the right values for the Sources entry': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'), - sources = proj.pbxSourcesBuildPhaseObj(), - sourceObj = sources.files[2]; + var newFile = proj.addSourceFile('Plugins/file.m'); + var sources = proj.pbxSourcesBuildPhaseObj(); + var sourceObj = sources.files[2]; test.equal(sourceObj.comment, 'file.m in Sources'); test.equal(sourceObj.value, newFile.uuid); @@ -152,13 +153,13 @@ exports.addSourceFile = { test.done(); }, 'should not add another entry anywhere': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length, - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length, - plugins = proj.pbxGroupByName('Plugins'), - sources = proj.pbxSourcesBuildPhaseObj(); + var newFile = proj.addSourceFile('Plugins/file.m'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; + var plugins = proj.pbxGroupByName('Plugins'); + var sources = proj.pbxSourcesBuildPhaseObj(); // duplicate! proj.addSourceFile('Plugins/file.m'); diff --git a/test/addStaticLibrary.js b/test/addStaticLibrary.js index d1b0ec6..5bdebec 100644 --- a/test/addStaticLibrary.js +++ b/test/addStaticLibrary.js @@ -15,19 +15,21 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); } function nonComments(obj) { - var keys = Object.keys(obj), - newObj = {}, i = 0; + var keys = Object.keys(obj); + var newObj = {}; + var i = 0; for (i; i < keys.length; i++) { if (!/_comment$/.test(keys[i])) { @@ -39,9 +41,11 @@ function nonComments(obj) { } function librarySearchPaths(proj) { - var configs = nonComments(proj.pbxXCBuildConfigurationSection()), - allPaths = [], - ids = Object.keys(configs), i, buildSettings; + var configs = nonComments(proj.pbxXCBuildConfigurationSection()); + var allPaths = []; + var ids = Object.keys(configs); + var i; + var buildSettings; for (i = 0; i< ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; @@ -134,9 +138,9 @@ exports.addStaticLibrary = { test.done(); }, 'should add the PBXFileReference object correctly': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.lastKnownFileType, 'archive.ar'); @@ -147,25 +151,27 @@ exports.addStaticLibrary = { test.done(); }, 'should add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); test.done(); }, 'should have the right values for the Sources entry': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'), - frameworks = proj.pbxFrameworksBuildPhaseObj(), - framework = frameworks.files[15]; + var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); + var framework = frameworks.files[15]; test.equal(framework.comment, 'libGoogleAnalytics.a in Frameworks'); test.equal(framework.value, newFile.uuid); test.done(); }, 'should set LIBRARY_SEARCH_PATHS for appropriate build configurations': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'), - configs = nonComments(proj.pbxXCBuildConfigurationSection()), - ids = Object.keys(configs), i, buildSettings; + var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + var configs = nonComments(proj.pbxXCBuildConfigurationSection()); + var ids = Object.keys(configs); + var i; + var buildSettings; for (i = 0; i< ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; @@ -178,10 +184,11 @@ exports.addStaticLibrary = { test.done(); }, 'should ensure LIBRARY_SEARCH_PATHS inherits defaults correctly': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'), - libraryPaths = librarySearchPaths(proj), - expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""', - i, current; + var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + var libraryPaths = librarySearchPaths(proj); + var expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""'; + var i; + var current; for (i = 0; i < libraryPaths.length; i++) { current = libraryPaths[i]; @@ -191,10 +198,11 @@ exports.addStaticLibrary = { test.done(); }, 'should ensure the new library is in LIBRARY_SEARCH_PATHS': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'), - libraryPaths = librarySearchPaths(proj), - expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""', - i, current; + var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + var libraryPaths = librarySearchPaths(proj); + var expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""'; + var i; + var current; for (i = 0; i < libraryPaths.length; i++) { current = libraryPaths[i]; @@ -205,8 +213,9 @@ exports.addStaticLibrary = { }, 'should add to the Plugins group, optionally': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a', - { plugin: true }), - plugins = proj.pbxGroupByName('Plugins'); + { plugin: true }); + + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); test.done(); @@ -217,10 +226,12 @@ exports.addStaticLibrary = { plugins.path = '"Test200/Plugins"'; var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', - { plugin: true }), - libraryPaths = librarySearchPaths(proj), - expectedPath = '"\\"$(SRCROOT)/Test200/Plugins\\""', - i, current; + { plugin: true }); + + var libraryPaths = librarySearchPaths(proj); + var expectedPath = '"\\"$(SRCROOT)/Test200/Plugins\\""'; + var i; + var current; for (i = 0; i < libraryPaths.length; i++) { current = libraryPaths[i]; @@ -235,10 +246,12 @@ exports.addStaticLibrary = { delete plugins.path; var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', - { plugin: true }), - libraryPaths = librarySearchPaths(proj), - expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet/Plugins\\""', - i, current; + { plugin: true }); + + var libraryPaths = librarySearchPaths(proj); + var expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet/Plugins\\""'; + var i; + var current; for (i = 0; i < libraryPaths.length; i++) { current = libraryPaths[i]; diff --git a/test/addTarget.js b/test/addTarget.js index 6e44625..8207e9d 100644 --- a/test/addTarget.js +++ b/test/addTarget.js @@ -15,19 +15,20 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); } -var TARGET_NAME = 'TestExtension', - TARGET_TYPE = 'app_extension', - TARGET_SUBFOLDER_NAME = 'TestExtensionFiles'; +var TARGET_NAME = 'TestExtension'; +var TARGET_TYPE = 'app_extension'; +var TARGET_SUBFOLDER_NAME = 'TestExtensionFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); @@ -94,9 +95,9 @@ exports.addTarget = { test.done(); }, 'should add debug and release configurations to build configuration list': function (test) { - var pbxXCBuildConfigurationSection = proj.pbxXCBuildConfigurationSection(), - pbxXCConfigurationList = proj.pbxXCConfigurationList(), - target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var pbxXCBuildConfigurationSection = proj.pbxXCBuildConfigurationSection(); + var pbxXCConfigurationList = proj.pbxXCConfigurationList(); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); test.ok(target.pbxNativeTarget.buildConfigurationList); test.ok(pbxXCConfigurationList[target.pbxNativeTarget.buildConfigurationList]); @@ -128,8 +129,8 @@ exports.addTarget = { test.done(); }, 'should add to build configuration list with default configuration name': function (test) { - var pbxXCConfigurationList = proj.pbxXCConfigurationList(), - target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var pbxXCConfigurationList = proj.pbxXCConfigurationList(); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); test.ok(target.pbxNativeTarget.buildConfigurationList); test.ok(pbxXCConfigurationList[target.pbxNativeTarget.buildConfigurationList]); @@ -138,8 +139,8 @@ exports.addTarget = { test.done(); }, 'should add to build configuration list with comment': function (test) { - var pbxXCConfigurationList = proj.pbxXCConfigurationList(), - target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var pbxXCConfigurationList = proj.pbxXCConfigurationList(); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); var buildCommentKey = target.pbxNativeTarget.buildConfigurationList + '_comment'; test.ok(pbxXCConfigurationList[buildCommentKey]); @@ -148,16 +149,15 @@ exports.addTarget = { test.done(); }, 'should create a new target and add source, framework, resource and header files and the corresponding build phases': function (test) { - var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME), - options = { 'target' : target.uuid }; - - var sourceFile = proj.addSourceFile('Plugins/file.m', options), - sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid), - resourceFile = proj.addResourceFile('assets.bundle', options), - resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid), - frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var options = { 'target' : target.uuid }; + var sourceFile = proj.addSourceFile('Plugins/file.m', options); + var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); + var resourceFile = proj.addResourceFile('assets.bundle', options); + var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); + var frameworkFile = proj.addFramework('libsqlite3.dylib', options); + frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), + headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addTargetDependency.js b/test/addTargetDependency.js index 37fe829..6034869 100644 --- a/test/addTargetDependency.js +++ b/test/addTargetDependency.js @@ -15,10 +15,11 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -91,8 +92,8 @@ exports.addTargetDependency = { test.done(); }, 'should create a PBXTargetDependency for each dependency target': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; @@ -102,8 +103,8 @@ exports.addTargetDependency = { test.done() }, 'should set right comment for each target dependency': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependencyCommentKey = target.dependencies[index].value + '_comment'; @@ -113,8 +114,8 @@ exports.addTargetDependency = { test.done() }, 'should set right comment for each dependency target': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependencyTargetUuid = target.dependencies[index].value; @@ -129,13 +130,13 @@ exports.addTargetDependency = { test.done(); }, 'should create a PBXContainerItemProxy for each PBXTargetDependency': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { - var dependency = target.dependencies[index].value, - targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var dependency = target.dependencies[index].value; + var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; test.ok(pbxContainerItemProxySection[targetProxy]); } @@ -143,9 +144,9 @@ exports.addTargetDependency = { test.done() }, 'should set right comment for each container item proxy': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependencyTargetUuid = target.dependencies[index].value; @@ -163,14 +164,14 @@ exports.addTargetDependency = { test.done(); }, 'should set each PBXContainerItemProxy`s remoteGlobalIDString correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target, - remoteGlobalIDStrings = []; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var remoteGlobalIDStrings = []; for (var index = 0; index < target.dependencies.length; index++) { - var dependency = target.dependencies[index].value, - targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var dependency = target.dependencies[index].value; + var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; remoteGlobalIDStrings.push(pbxContainerItemProxySection[targetProxy]['remoteGlobalIDString']); } @@ -179,14 +180,14 @@ exports.addTargetDependency = { test.done() }, 'should set each PBXContainerItemProxy`s remoteInfo correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target, - remoteInfoArray = []; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var remoteInfoArray = []; for (var index = 0; index < target.dependencies.length; index++) { - var dependency = target.dependencies[index].value, - targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var dependency = target.dependencies[index].value; + var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; remoteInfoArray.push(pbxContainerItemProxySection[targetProxy]['remoteInfo']); } @@ -195,13 +196,13 @@ exports.addTargetDependency = { test.done() }, 'should set each PBXContainerItemProxy`s containerPortal correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { - var dependency = target.dependencies[index].value, - targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var dependency = target.dependencies[index].value; + var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; test.equal(pbxContainerItemProxySection[targetProxy]['containerPortal'], proj.hash.project['rootObject']); } @@ -209,13 +210,13 @@ exports.addTargetDependency = { test.done() }, 'should set each PBXContainerItemProxy`s containerPortal_comment correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { - var dependency = target.dependencies[index].value, - targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var dependency = target.dependencies[index].value; + var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; test.equal(pbxContainerItemProxySection[targetProxy]['containerPortal_comment'], proj.hash.project['rootObject_comment']); } @@ -223,13 +224,13 @@ exports.addTargetDependency = { test.done() }, 'should set each PBXContainerItemProxy`s proxyType correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency'], - pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy'], - target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; + var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { - var dependency = target.dependencies[index].value, - targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var dependency = target.dependencies[index].value; + var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; test.equal(pbxContainerItemProxySection[targetProxy]['proxyType'], 1); } diff --git a/test/addToPbxFileReferenceSection.js b/test/addToPbxFileReferenceSection.js index d69abbc..1be6046 100644 --- a/test/addToPbxFileReferenceSection.js +++ b/test/addToPbxFileReferenceSection.js @@ -15,11 +15,12 @@ under the License. */ -var jsonProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(jsonProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - myProj = new pbx('.'); +var jsonProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(jsonProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var myProj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/addWatch2App.js b/test/addWatch2App.js index 2dd72f5..8375ffa 100644 --- a/test/addWatch2App.js +++ b/test/addWatch2App.js @@ -15,19 +15,20 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); } -var TARGET_NAME = 'TestWatchApp', - TARGET_TYPE = 'watch2_app', - TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; +var TARGET_NAME = 'TestWatchApp'; +var TARGET_TYPE = 'watch2_app'; +var TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); @@ -76,16 +77,15 @@ exports.addWatchApp = { test.done(); }, 'should create a new watch2 app target and add source, framework, resource and header files and the corresponding build phases': function (test) { - var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME), - options = { 'target' : target.uuid }; - - var sourceFile = proj.addSourceFile('Plugins/file.m', options), - sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid), - resourceFile = proj.addResourceFile('assets.bundle', options), - resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid), - frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var options = { 'target' : target.uuid }; + var sourceFile = proj.addSourceFile('Plugins/file.m', options); + var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); + var resourceFile = proj.addResourceFile('assets.bundle', options); + var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); + var frameworkFile = proj.addFramework('libsqlite3.dylib', options); + frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), + headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatch2Extension.js b/test/addWatch2Extension.js index 302b752..121fd1d 100644 --- a/test/addWatch2Extension.js +++ b/test/addWatch2Extension.js @@ -15,19 +15,20 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); } -var TARGET_NAME = 'TestWatchExtension', - TARGET_TYPE = 'watch2_extension', - TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles'; +var TARGET_NAME = 'TestWatchExtension'; +var TARGET_TYPE = 'watch2_extension'; +var TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); @@ -55,16 +56,15 @@ exports.addWatchExtension = { test.done(); }, 'should create a new watch2 extension target and add source, framework, resource and header files and the corresponding build phases': function (test) { - var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME), - options = { 'target' : target.uuid }; - - var sourceFile = proj.addSourceFile('Plugins/file.m', options), - sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid), - resourceFile = proj.addResourceFile('assets.bundle', options), - resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid), - frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var options = { 'target' : target.uuid }; + var sourceFile = proj.addSourceFile('Plugins/file.m', options); + var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); + var resourceFile = proj.addResourceFile('assets.bundle', options); + var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); + var frameworkFile = proj.addFramework('libsqlite3.dylib', options); + frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), + headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatchApp.js b/test/addWatchApp.js index b1b603d..746994f 100644 --- a/test/addWatchApp.js +++ b/test/addWatchApp.js @@ -15,19 +15,20 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); } -var TARGET_NAME = 'TestWatchApp', - TARGET_TYPE = 'watch_app', - TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; +var TARGET_NAME = 'TestWatchApp'; +var TARGET_TYPE = 'watch_app'; +var TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); @@ -76,16 +77,15 @@ exports.addWatchApp = { test.done(); }, 'should create a new watch app target and add source, framework, resource and header files and the corresponding build phases': function (test) { - var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME), - options = { 'target' : target.uuid }; - - var sourceFile = proj.addSourceFile('Plugins/file.m', options), - sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid), - resourceFile = proj.addResourceFile('assets.bundle', options), - resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid), - frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var options = { 'target' : target.uuid }; + var sourceFile = proj.addSourceFile('Plugins/file.m', options); + var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); + var resourceFile = proj.addResourceFile('assets.bundle', options); + var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); + var frameworkFile = proj.addFramework('libsqlite3.dylib', options); + frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), + headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatchExtension.js b/test/addWatchExtension.js index 9410488..5be4649 100644 --- a/test/addWatchExtension.js +++ b/test/addWatchExtension.js @@ -15,19 +15,20 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); } -var TARGET_NAME = 'TestWatchExtension', - TARGET_TYPE = 'watch_extension', - TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles'; +var TARGET_NAME = 'TestWatchExtension'; +var TARGET_TYPE = 'watch_extension'; +var TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); @@ -54,16 +55,15 @@ exports.addWatchExtension = { test.done(); }, 'should create a new watch extension target and add source, framework, resource and header files and the corresponding build phases': function (test) { - var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME), - options = { 'target' : target.uuid }; - - var sourceFile = proj.addSourceFile('Plugins/file.m', options), - sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid), - resourceFile = proj.addResourceFile('assets.bundle', options), - resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid), - frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); + var options = { 'target' : target.uuid }; + var sourceFile = proj.addSourceFile('Plugins/file.m', options); + var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); + var resourceFile = proj.addResourceFile('assets.bundle', options); + var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); + var frameworkFile = proj.addFramework('libsqlite3.dylib', options); + frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), + headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addXCConfigurationList.js b/test/addXCConfigurationList.js index 6ef74c3..00bea01 100644 --- a/test/addXCConfigurationList.js +++ b/test/addXCConfigurationList.js @@ -15,34 +15,37 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - proj = new pbx('.'), - debugConfiguration = { - isa: 'XCBuildConfiguration', - buildSettings: { - GCC_PREPROCESSOR_DEFINITIONS: [ - '"DEBUG=1"', - '"$(inherited)"', - ], - INFOPLIST_FILE: "Info.Plist", - LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', - PRODUCT_NAME: '"${TARGET_NAME}"', - SKIP_INSTALL: 'YES' - }, - name: 'Debug' +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var proj = new pbx('.'); + +var debugConfiguration = { + isa: 'XCBuildConfiguration', + buildSettings: { + GCC_PREPROCESSOR_DEFINITIONS: [ + '"DEBUG=1"', + '"$(inherited)"', + ], + INFOPLIST_FILE: "Info.Plist", + LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', + PRODUCT_NAME: '"${TARGET_NAME}"', + SKIP_INSTALL: 'YES' + }, + name: 'Debug' +}; + +var releaseConfiguration = { + isa: 'XCBuildConfiguration', + buildSettings: { + INFOPLIST_FILE: "Info.Plist", + LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', + PRODUCT_NAME: '"${TARGET_NAME}"', + SKIP_INSTALL: 'YES' }, - releaseConfiguration = { - isa: 'XCBuildConfiguration', - buildSettings: { - INFOPLIST_FILE: "Info.Plist", - LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', - PRODUCT_NAME: '"${TARGET_NAME}"', - SKIP_INSTALL: 'YES' - }, - name: 'Release' - }; + name: 'Release' +}; function cleanHash() { return JSON.parse(fullProjectStr); @@ -55,24 +58,24 @@ exports.setUp = function (callback) { exports.addXCConfigurationList = { 'should return an XCConfigurationList': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); test.ok(typeof xcConfigurationList === 'object'); test.done(); }, 'should set a uuid on the XCConfigurationList': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); test.ok(xcConfigurationList.uuid); test.done(); }, 'should add configurations to pbxBuildConfigurationSection': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), - xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(); + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { var configuration = xcConfigurationListConfigurations[index]; @@ -82,30 +85,30 @@ exports.addXCConfigurationList = { test.done(); }, 'should add XCConfigurationList to pbxXCConfigurationListSection': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); test.ok(pbxXCConfigurationListSection[xcConfigurationList.uuid]); test.done(); }, 'should add XCConfigurationList object correctly': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), - xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), + xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; test.deepEqual(xcConfigurationListInPbx, xcConfigurationList.xcConfigurationList); test.done(); }, 'should add correct configurations to XCConfigurationList and to pbxBuildConfigurationSection': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); - pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), - xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations, - expectedConfigurations = [], - xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); + pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), + xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), + xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations, + expectedConfigurations = [], + xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { var configuration = xcConfigurationListConfigurations[index]; @@ -117,10 +120,10 @@ exports.addXCConfigurationList = { test.done(); }, 'should set comments for pbxBuildConfigurations': function (test) { - var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(), - pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), - xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; + var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); + var pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(); + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { var configuration = xcConfigurationListConfigurations[index]; diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index 76477ed..c98962c 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -15,14 +15,15 @@ under the License. */ -var jsonProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(jsonProject), - path = require('path'), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'), - singleDataModelFilePath = __dirname + '/fixtures/single-data-model.xcdatamodeld', - multipleDataModelFilePath = __dirname + '/fixtures/multiple-data-model.xcdatamodeld'; +var jsonProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(jsonProject); +var path = require('path'); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); +var singleDataModelFilePath = __dirname + '/fixtures/single-data-model.xcdatamodeld'; +var multipleDataModelFilePath = __dirname + '/fixtures/multiple-data-model.xcdatamodeld'; function cleanHash() { return JSON.parse(fullProjectStr); @@ -53,16 +54,16 @@ exports.dataModelDocument = { test.done() }, 'should set an optional target on the pbxFile': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath, undefined, { target: target }), - target = proj.findTargetKey('TestApp'); + var newFile = proj.addDataModelDocument(singleDataModelFilePath, undefined, { target: target }); + var target = proj.findTargetKey('TestApp'); test.equal(newFile.target, target); test.done() }, 'should populate the PBXBuildFile section with 2 fields': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addDataModelDocument(singleDataModelFilePath); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(59 + 1, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -71,9 +72,9 @@ exports.dataModelDocument = { test.done(); }, 'should populate the PBXFileReference section with 2 fields for single model document': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addDataModelDocument(singleDataModelFilePath); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(66 + 2, frsLength); test.ok(fileRefSection[newFile.models[0].fileRef]); @@ -82,9 +83,9 @@ exports.dataModelDocument = { test.done(); }, 'should populate the PBXFileReference section with 2 fields for each model of a model document': function (test) { - var newFile = proj.addDataModelDocument(multipleDataModelFilePath), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addDataModelDocument(multipleDataModelFilePath); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(66 + 2 * 2, frsLength); test.ok(fileRefSection[newFile.models[0].fileRef]); @@ -109,9 +110,9 @@ exports.dataModelDocument = { test.done(); }, 'should add to group specified by key': function (test) { - var group = 'Frameworks', - newFile = proj.addDataModelDocument(singleDataModelFilePath, proj.findPBXGroupKey({ name: group })); - groupChildren = proj.pbxGroupByName(group).children; + var group = 'Frameworks'; + var newFile = proj.addDataModelDocument(singleDataModelFilePath, proj.findPBXGroupKey({ name: group })); + groupChildren = proj.pbxGroupByName(group).children; var found = false; for (var index in groupChildren) { @@ -124,9 +125,9 @@ exports.dataModelDocument = { test.done(); }, 'should add to group specified by name': function (test) { - var group = 'Frameworks', - newFile = proj.addDataModelDocument(singleDataModelFilePath, group); - groupChildren = proj.pbxGroupByName(group).children; + var group = 'Frameworks'; + var newFile = proj.addDataModelDocument(singleDataModelFilePath, group); + groupChildren = proj.pbxGroupByName(group).children; var found = false; for (var index in groupChildren) { @@ -139,31 +140,31 @@ exports.dataModelDocument = { test.done(); }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath), - sources = proj.pbxSourcesBuildPhaseObj(); + var newFile = proj.addDataModelDocument(singleDataModelFilePath); + var sources = proj.pbxSourcesBuildPhaseObj(); test.equal(sources.files.length, 2 + 1); test.done(); }, 'should create a XCVersionGroup section': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath), - xcVersionGroupSection = proj.xcVersionGroupSection(); + var newFile = proj.addDataModelDocument(singleDataModelFilePath); + var xcVersionGroupSection = proj.xcVersionGroupSection(); test.ok(xcVersionGroupSection[newFile.fileRef]); test.done(); }, 'should populate the XCVersionGroup comment correctly': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath), - xcVersionGroupSection = proj.xcVersionGroupSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.addDataModelDocument(singleDataModelFilePath); + var xcVersionGroupSection = proj.xcVersionGroupSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(xcVersionGroupSection[commentKey], path.basename(singleDataModelFilePath)); test.done(); }, 'should add the XCVersionGroup object correctly': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath), - xcVersionGroupSection = proj.xcVersionGroupSection(), - xcVersionGroupEntry = xcVersionGroupSection[newFile.fileRef]; + var newFile = proj.addDataModelDocument(singleDataModelFilePath); + var xcVersionGroupSection = proj.xcVersionGroupSection(); + var xcVersionGroupEntry = xcVersionGroupSection[newFile.fileRef]; test.equal(xcVersionGroupEntry.isa, 'XCVersionGroup'); test.equal(xcVersionGroupEntry.children[0], newFile.models[0].fileRef); diff --git a/test/group.js b/test/group.js index af2454e..1088a83 100644 --- a/test/group.js +++ b/test/group.js @@ -15,10 +15,11 @@ under the License. */ -var pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - project, - projectHash; +var pbx = require('../lib/pbxProject'); + +var pbxFile = require('../lib/pbxFile'); +var project; +var projectHash; var findChildInGroup = function(obj, target) { var found = false; diff --git a/test/knownRegions.js b/test/knownRegions.js index 08ce454..6d4a0cc 100644 --- a/test/knownRegions.js +++ b/test/knownRegions.js @@ -15,10 +15,11 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - project = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var project = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/multipleTargets.js b/test/multipleTargets.js index dbb945f..a94c8e0 100644 --- a/test/multipleTargets.js +++ b/test/multipleTargets.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/multiple-targets') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/multiple-targets'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/parser/build-config.js b/test/parser/build-config.js index 465c352..9bc8b54 100644 --- a/test/parser/build-config.js +++ b/test/parser/build-config.js @@ -15,14 +15,15 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/build-config.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - util = require('util'), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/build-config.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var util = require('util'); +var project = rawProj.project; exports['should parse the build config section'] = function (test) { // if it gets this far it's worked @@ -30,17 +31,17 @@ exports['should parse the build config section'] = function (test) { } exports['should read a decimal value correctly'] = function (test) { - var xcbConfig = project.objects['XCBuildConfiguration'], - debugSettings = xcbConfig['1D6058950D05DD3E006BFB54'].buildSettings; + var xcbConfig = project.objects['XCBuildConfiguration']; + var debugSettings = xcbConfig['1D6058950D05DD3E006BFB54'].buildSettings; test.strictEqual(debugSettings['IPHONEOS_DEPLOYMENT_TARGET'], '3.0'); test.done(); } exports['should read an escaped value correctly'] = function (test) { - var xcbConfig = project.objects['XCBuildConfiguration'], - debugSettings = xcbConfig['C01FCF4F08A954540054247B'].buildSettings, - expt = '"\\"$(PHONEGAPLIB)/Classes/JSON\\" \\"$(PHONEGAPLIB)/Classes\\""'; + var xcbConfig = project.objects['XCBuildConfiguration']; + var debugSettings = xcbConfig['C01FCF4F08A954540054247B'].buildSettings; + var expt = '"\\"$(PHONEGAPLIB)/Classes/JSON\\" \\"$(PHONEGAPLIB)/Classes\\""'; test.strictEqual(debugSettings['USER_HEADER_SEARCH_PATHS'], expt); test.done(); diff --git a/test/parser/comments.js b/test/parser/comments.js index 7be4c38..f2a3a0e 100644 --- a/test/parser/comments.js +++ b/test/parser/comments.js @@ -15,11 +15,12 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/comments.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar); +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/comments.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); // Cordova 1.8 has the Apache headers as comments in the pbxproj file // I DON'T KNOW WHY diff --git a/test/parser/dotsInNames.js b/test/parser/dotsInNames.js index 4121bba..232d66f 100644 --- a/test/parser/dotsInNames.js +++ b/test/parser/dotsInNames.js @@ -15,17 +15,18 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/dots-in-names.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/dots-in-names.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should parse com.apple.BackgroundModes'] = function (test) { - var targets = project.attributes.TargetAttributes['1D6058900D05DD3D006BFB54'], - backgroundModes = targets.SystemCapabilities['com.apple.BackgroundModes']; + var targets = project.attributes.TargetAttributes['1D6058900D05DD3D006BFB54']; + var backgroundModes = targets.SystemCapabilities['com.apple.BackgroundModes']; test.deepEqual(backgroundModes, {enabled: 1}); test.done() diff --git a/test/parser/file-references.js b/test/parser/file-references.js index 4275378..45e46d8 100644 --- a/test/parser/file-references.js +++ b/test/parser/file-references.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/file-references.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/file-references.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should have a PBXFileReference section'] = function (test) { test.ok(project.objects['PBXFileReference']); diff --git a/test/parser/hash.js b/test/parser/hash.js index 6ec8106..1422cb5 100644 --- a/test/parser/hash.js +++ b/test/parser/hash.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/hash.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/hash.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should have the top-line comment in place'] = function (test) { test.equals(rawProj.headComment, '!$*UTF8*$!'); diff --git a/test/parser/header-search.js b/test/parser/header-search.js index 226c301..5696f21 100644 --- a/test/parser/header-search.js +++ b/test/parser/header-search.js @@ -15,18 +15,19 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/header-search.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/header-search.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should read a decimal value correctly'] = function (test) { - var debug = project.objects['XCBuildConfiguration']['C01FCF4F08A954540054247B'], - hsPaths = debug.buildSettings['HEADER_SEARCH_PATHS'], - expected = '"\\"$(TARGET_BUILD_DIR)/usr/local/lib/include\\""'; + var debug = project.objects['XCBuildConfiguration']['C01FCF4F08A954540054247B']; + var hsPaths = debug.buildSettings['HEADER_SEARCH_PATHS']; + var expected = '"\\"$(TARGET_BUILD_DIR)/usr/local/lib/include\\""'; test.equal(hsPaths[0], expected); test.done(); diff --git a/test/parser/section-entries.js b/test/parser/section-entries.js index 56d578c..a55ad78 100644 --- a/test/parser/section-entries.js +++ b/test/parser/section-entries.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/section-entries.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/section-entries.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should have a PBXVariantGroup section'] = function (test) { test.ok(project.objects['PBXVariantGroup']); diff --git a/test/parser/section-split.js b/test/parser/section-split.js index cd17247..39b6d1b 100644 --- a/test/parser/section-split.js +++ b/test/parser/section-split.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/section-split.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/section-split.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should have a PBXTargetDependency section'] = function (test) { test.ok(project.objects['PBXTargetDependency']); diff --git a/test/parser/section.js b/test/parser/section.js index 65e65fa..eebea10 100644 --- a/test/parser/section.js +++ b/test/parser/section.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/section.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/section.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should have a PBXTargetDependency section'] = function (test) { test.ok(project.objects['PBXTargetDependency']); diff --git a/test/parser/two-sections.js b/test/parser/two-sections.js index 3f8e1f4..642b6c7 100644 --- a/test/parser/two-sections.js +++ b/test/parser/two-sections.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/two-sections.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/two-sections.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should parse a project with two sections'] = function (test) { // if it gets this far it's worked diff --git a/test/parser/with_array.js b/test/parser/with_array.js index b63ef50..52030cd 100644 --- a/test/parser/with_array.js +++ b/test/parser/with_array.js @@ -15,13 +15,14 @@ under the License. */ -var PEG = require('pegjs'), - fs = require('fs'), - pbx = fs.readFileSync('test/parser/projects/with_array.pbxproj', 'utf-8'), - grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'), - parser = PEG.generate(grammar), - rawProj = parser.parse(pbx), - project = rawProj.project; +var PEG = require('pegjs'); + +var fs = require('fs'); +var pbx = fs.readFileSync('test/parser/projects/with_array.pbxproj', 'utf-8'); +var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); +var parser = PEG.generate(grammar); +var rawProj = parser.parse(pbx); +var project = rawProj.project; exports['should parse arrays with commented entries'] = function (test) { test.ok(project.files instanceof Array); diff --git a/test/pbxFile.js b/test/pbxFile.js index 4f0d1a2..8804b1d 100644 --- a/test/pbxFile.js +++ b/test/pbxFile.js @@ -129,8 +129,8 @@ exports['group'] = { test.done(); }, 'should be Resources for all other files': function (test) { - var headerFile = new pbxFile('Plugins/ChildBrowser.h'), - xibFile = new pbxFile('Plugins/ChildBrowser.xib'); + var headerFile = new pbxFile('Plugins/ChildBrowser.h'); + var xibFile = new pbxFile('Plugins/ChildBrowser.xib'); test.equal('Resources', headerFile.group); test.equal('Resources', xibFile.group); diff --git a/test/pbxItemByComment.js b/test/pbxItemByComment.js index 5bee287..1feebe1 100644 --- a/test/pbxItemByComment.js +++ b/test/pbxItemByComment.js @@ -15,10 +15,11 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/pbxProject.js b/test/pbxProject.js index c076b96..55333af 100644 --- a/test/pbxProject.js +++ b/test/pbxProject.js @@ -15,11 +15,12 @@ under the License. */ -var pbx = require('../lib/pbxProject'), - buildConfig = require('./fixtures/buildFiles'), - jsonProject = require('./fixtures/full-project'), - fs = require('fs'), - project; +var pbx = require('../lib/pbxProject'); + +var buildConfig = require('./fixtures/buildFiles'); +var jsonProject = require('./fixtures/full-project'); +var fs = require('fs'); +var project; exports['creation'] = { 'should create a pbxProject with the new operator': function (test) { @@ -38,21 +39,21 @@ exports['creation'] = { exports['parseSync function'] = { 'should return the hash object': function (test) { - var myProj = new pbx('test/parser/projects/hash.pbxproj') - , projHash = myProj.parseSync(); - test.ok(projHash); - test.done(); + var myProj = new pbx('test/parser/projects/hash.pbxproj'); + var projHash = myProj.parseSync(); + test.ok(projHash); + test.done(); }, 'should contain valid data in the returned objects hash': function (test) { - var myProj = new pbx('test/parser/projects/hash.pbxproj') - , projHash = myProj.parseSync(); - test.ok(projHash); + var myProj = new pbx('test/parser/projects/hash.pbxproj'); + var projHash = myProj.parseSync(); + test.ok(projHash); - test.equal(projHash.hash.project.archiveVersion, 1); - test.equal(projHash.hash.project.objectVersion, 45); - test.equal(projHash.hash.project.nonObject, '29B97313FDCFA39411CA2CEF'); + test.equal(projHash.hash.project.archiveVersion, 1); + test.equal(projHash.hash.project.objectVersion, 45); + test.equal(projHash.hash.project.nonObject, '29B97313FDCFA39411CA2CEF'); - test.done(); + test.done(); }, } @@ -115,8 +116,8 @@ exports['parse function'] = { exports['allUuids function'] = { 'should return the right amount of uuids': function (test) { - var project = new pbx('.'), - uuids; + var project = new pbx('.'); + var uuids; project.hash = buildConfig; uuids = project.allUuids(); @@ -128,25 +129,25 @@ exports['allUuids function'] = { exports['generateUuid function'] = { 'should return a 24 character string': function (test) { - var project = new pbx('.'), - newUUID; + var project = new pbx('.'); + var newUUID; - project.hash = buildConfig; - newUUID = project.generateUuid(); + project.hash = buildConfig; + newUUID = project.generateUuid(); - test.equal(newUUID.length, 24); - test.done(); + test.equal(newUUID.length, 24); + test.done(); }, 'should be an uppercase hex string': function (test) { - var project = new pbx('.'), - uHex = /^[A-F0-9]{24}$/, - newUUID; + var project = new pbx('.'); + var uHex = /^[A-F0-9]{24}$/; + var newUUID; - project.hash = buildConfig; - newUUID = project.generateUuid(); + project.hash = buildConfig; + newUUID = project.generateUuid(); - test.ok(uHex.test(newUUID)); - test.done(); + test.ok(uHex.test(newUUID)); + test.done(); } } diff --git a/test/pbxTargetByName.js b/test/pbxTargetByName.js index 15c956d..923b7ff 100644 --- a/test/pbxTargetByName.js +++ b/test/pbxTargetByName.js @@ -15,10 +15,11 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); diff --git a/test/pbxWriter.js b/test/pbxWriter.js index f1e2ee4..3b68396 100644 --- a/test/pbxWriter.js +++ b/test/pbxWriter.js @@ -15,9 +15,10 @@ under the License. */ -var pbx = require('../lib/pbxProject'), - fs = require('fs'), - myProj; +var pbx = require('../lib/pbxProject'); + +var fs = require('fs'); +var myProj; function testProjectContents(filename, test, expectedFilename) { var myProj = new pbx(filename); @@ -41,16 +42,16 @@ function testProjectContents(filename, test, expectedFilename) { // for debugging failing tests function testContentsInDepth(filename, test) { - var myProj = new pbx(filename), - content = fs.readFileSync(filename, 'utf-8'); + var myProj = new pbx(filename); + var content = fs.readFileSync(filename, 'utf-8'); // normalize tabs vs strings content = content.replace(/ /g, '\t'); myProj.parse(function (err, projHash) { - var written = myProj.writeSync(), - writtenLines = written.split('\n') - contentLines = content.split('\n') + var written = myProj.writeSync(); + var writtenLines = written.split('\n'); + contentLines = content.split('\n') test.equal(writtenLines.length, contentLines.length); diff --git a/test/removeFramework.js b/test/removeFramework.js index 20cdbde..7693b39 100644 --- a/test/removeFramework.js +++ b/test/removeFramework.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project'), - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -31,8 +32,9 @@ exports.setUp = function (callback) { } function nonComments(obj) { - var keys = Object.keys(obj), - newObj = {}, i = 0; + var keys = Object.keys(obj); + var newObj = {}; + var i = 0; for (i; i < keys.length; i++) { if (!/_comment$/.test(keys[i])) { @@ -44,9 +46,11 @@ function nonComments(obj) { } function frameworkSearchPaths(proj) { - var configs = nonComments(proj.pbxXCBuildConfigurationSection()), - allPaths = [], - ids = Object.keys(configs), i, buildSettings; + var configs = nonComments(proj.pbxXCBuildConfigurationSection()); + var allPaths = []; + var ids = Object.keys(configs); + var i; + var buildSettings; for (i = 0; i< ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; @@ -101,9 +105,9 @@ exports.removeFramework = { test.done(); }, 'should remove 2 fields from the PBXBuildFile section': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addFramework('libsqlite3.dylib'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -120,45 +124,45 @@ exports.removeFramework = { test.done(); }, 'should remove from the Frameworks PBXGroup': function (test) { - var newLength = proj.pbxGroupByName('Frameworks').children.length + 1, - newFile = proj.addFramework('libsqlite3.dylib'), - frameworks = proj.pbxGroupByName('Frameworks'); + var newLength = proj.pbxGroupByName('Frameworks').children.length + 1; + var newFile = proj.addFramework('libsqlite3.dylib'); + var frameworks = proj.pbxGroupByName('Frameworks'); test.equal(frameworks.children.length, newLength); - var deletedFile = proj.removeFramework('libsqlite3.dylib'), - newLength = newLength - 1; + var deletedFile = proj.removeFramework('libsqlite3.dylib'); + var newLength = newLength - 1; test.equal(frameworks.children.length, newLength); test.done(); }, 'should remove from the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var newFile = proj.addFramework('libsqlite3.dylib'); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); - var deletedFile = proj.removeFramework('libsqlite3.dylib'), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var deletedFile = proj.removeFramework('libsqlite3.dylib'); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); test.done(); }, 'should remove custom frameworks': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true }), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true }); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); - var deletedFile = proj.removeFramework('/path/to/Custom.framework', { customFramework: true }), - frameworks = proj.pbxFrameworksBuildPhaseObj(); + var deletedFile = proj.removeFramework('/path/to/Custom.framework', { customFramework: true }); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); var frameworkPaths = frameworkSearchPaths(proj); - expectedPath = '"/path/to"'; + expectedPath = '"/path/to"'; for (i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; @@ -168,18 +172,18 @@ exports.removeFramework = { test.done(); }, 'should remove embedded frameworks': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true, embed:true, sign:true }), - frameworks = proj.pbxFrameworksBuildPhaseObj(), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true, embed:true, sign:true }); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(frameworks.files.length, 16); test.equal(62, bfsLength); - var deletedFile = proj.removeFramework('/path/to/Custom.framework', { customFramework: true, embed:true }), - frameworks = proj.pbxFrameworksBuildPhaseObj(), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var deletedFile = proj.removeFramework('/path/to/Custom.framework', { customFramework: true, embed:true }); + var frameworks = proj.pbxFrameworksBuildPhaseObj(); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(frameworks.files.length, 15); test.equal(58, bfsLength); diff --git a/test/removeHeaderFile.js b/test/removeHeaderFile.js index acda161..21dd63a 100644 --- a/test/removeHeaderFile.js +++ b/test/removeHeaderFile.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -54,17 +55,17 @@ exports.removeHeaderFile = { test.done() }, 'should remove 2 fields from the PBXFileReference section': function (test) { - var newFile = proj.addHeaderFile('file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addHeaderFile('file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); test.ok(fileRefSection[newFile.fileRef + '_comment']); - var deletedFile = proj.removeHeaderFile('file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var deletedFile = proj.removeHeaderFile('file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(66, frsLength); test.ok(!fileRefSection[deletedFile.fileRef]); @@ -73,23 +74,23 @@ exports.removeHeaderFile = { test.done(); }, 'should remove comment from the PBXFileReference correctly': function (test) { - var newFile = proj.addHeaderFile('file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.addHeaderFile('file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'file.h'); - var deletedFile = proj.removeHeaderFile('file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = deletedFile.fileRef + '_comment'; + var deletedFile = proj.removeHeaderFile('file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = deletedFile.fileRef + '_comment'; test.ok(!fileRefSection[commentKey]); test.done(); }, 'should remove the PBXFileReference object correctly': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addHeaderFile('Plugins/file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.fileEncoding, 4); @@ -98,22 +99,22 @@ exports.removeHeaderFile = { test.equal(fileRefEntry.path, '"file.h"'); test.equal(fileRefEntry.sourceTree, '""'); - var deletedFile = proj.removeHeaderFile('Plugins/file.h'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[deletedFile.fileRef]; + var deletedFile = proj.removeHeaderFile('Plugins/file.h'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[deletedFile.fileRef]; test.ok(!fileRefEntry); test.done(); }, 'should remove from the Plugins PBXGroup group': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'), - plugins = proj.pbxGroupByName('Plugins'); + var newFile = proj.addHeaderFile('Plugins/file.h'); + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); - var deletedFile = proj.removeHeaderFile('Plugins/file.h'), - plugins = proj.pbxGroupByName('Plugins'); + var deletedFile = proj.removeHeaderFile('Plugins/file.h'); + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 0); diff --git a/test/removeResourceFile.js b/test/removeResourceFile.js index bda48f9..bfde732 100644 --- a/test/removeResourceFile.js +++ b/test/removeResourceFile.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -65,17 +66,17 @@ exports.removeResourceFile = { test.done() }, 'should remove 2 fields from the PBXBuildFile section': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.addResourceFile('assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); test.ok(buildFileSection[newFile.uuid + '_comment']); - var deletedFile = proj.removeResourceFile('assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var deletedFile = proj.removeResourceFile('assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(58, bfsLength); test.ok(!buildFileSection[deletedFile.uuid]); @@ -84,49 +85,49 @@ exports.removeResourceFile = { test.done(); }, 'should remove the PBXBuildFile comment correctly': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var newFile = proj.addResourceFile('assets.bundle'); + var commentKey = newFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.equal(buildFileSection[commentKey], 'assets.bundle in Resources'); - var deletedFile = proj.removeResourceFile('assets.bundle'), - commentKey = deletedFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var deletedFile = proj.removeResourceFile('assets.bundle'); + var commentKey = deletedFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.ok(!buildFileSection[commentKey]); test.done(); }, 'should remove the PBXBuildFile object correctly': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.addResourceFile('assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); test.equal(buildFileEntry.fileRef_comment, 'assets.bundle'); - var deletedFile = proj.removeResourceFile('assets.bundle'), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[deletedFile.uuid]; + var deletedFile = proj.removeResourceFile('assets.bundle'); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[deletedFile.uuid]; test.ok(!buildFileEntry); test.done(); }, 'should remove 2 fields from the PBXFileReference section': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.addResourceFile('assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); test.ok(fileRefSection[newFile.fileRef + '_comment']); - var deletedFile = proj.removeResourceFile('assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var deletedFile = proj.removeResourceFile('assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(66, frsLength); test.ok(!fileRefSection[deletedFile.fileRef]); @@ -135,15 +136,15 @@ exports.removeResourceFile = { test.done(); }, 'should populate the PBXFileReference comment correctly': function (test) { - var newFile = proj.addResourceFile('assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.addResourceFile('assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'assets.bundle'); - var deletedFile = proj.removeResourceFile('assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = deletedFile.fileRef + '_comment'; + var deletedFile = proj.removeResourceFile('assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = deletedFile.fileRef + '_comment'; test.ok(!fileRefSection[commentKey]); test.done(); @@ -151,9 +152,9 @@ exports.removeResourceFile = { 'should remove the PBXFileReference object correctly': function (test) { delete proj.pbxGroupByName('Resources').path; - var newFile = proj.addResourceFile('Resources/assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.equal(fileRefEntry.isa, 'PBXFileReference'); test.equal(fileRefEntry.fileEncoding, undefined); @@ -162,34 +163,34 @@ exports.removeResourceFile = { test.equal(fileRefEntry.path, '"Resources/assets.bundle"'); test.equal(fileRefEntry.sourceTree, '""'); - var deletedFile = proj.removeResourceFile('Resources/assets.bundle'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[deletedFile.fileRef]; + var deletedFile = proj.removeResourceFile('Resources/assets.bundle'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[deletedFile.fileRef]; test.ok(!fileRefEntry); test.done(); }, 'should remove from the Resources PBXGroup group': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'), - resources = proj.pbxGroupByName('Resources'); + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 10); - var deletedFile = proj.removeResourceFile('Resources/assets.bundle'), - resources = proj.pbxGroupByName('Resources'); + var deletedFile = proj.removeResourceFile('Resources/assets.bundle'); + var resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 9); test.done(); }, 'should remove from the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'), - sources = proj.pbxResourcesBuildPhaseObj(); + var newFile = proj.addResourceFile('Resources/assets.bundle'); + var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 13); - var deletedFile = proj.removeResourceFile('Resources/assets.bundle'), - sources = proj.pbxResourcesBuildPhaseObj(); + var deletedFile = proj.removeResourceFile('Resources/assets.bundle'); + var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 12); test.done(); diff --git a/test/removeSourceFile.js b/test/removeSourceFile.js index de7895e..8086853 100644 --- a/test/removeSourceFile.js +++ b/test/removeSourceFile.js @@ -15,11 +15,12 @@ under the License. */ -var fullProject = require('./fixtures/full-project') - fullProjectStr = JSON.stringify(fullProject), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'); +var fullProject = require('./fixtures/full-project'); + +var fullProjectStr = JSON.stringify(fullProject); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); function cleanHash() { return JSON.parse(fullProjectStr); @@ -54,9 +55,9 @@ exports.removeSourceFile = { }, 'should remove 2 fields from the PBXBuildFile section': function (test) { proj.addSourceFile('file.m'); - var newFile = proj.removeSourceFile('file.m'), - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var newFile = proj.removeSourceFile('file.m'); + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(58, bfsLength); test.ok(!buildFileSection[newFile.uuid]); @@ -66,17 +67,17 @@ exports.removeSourceFile = { }, 'should remove comment from the PBXBuildFile correctly': function (test) { proj.addSourceFile('file.m'); - var newFile = proj.removeSourceFile('file.m'), - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var newFile = proj.removeSourceFile('file.m'); + var commentKey = newFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.notEqual(!buildFileSection[commentKey], 'file.m in Sources'); test.done(); }, 'should remove the PBXBuildFile object correctly': function (test) { proj.addSourceFile('file.m'); - var newFile = proj.removeSourceFile('file.m'), - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var newFile = proj.removeSourceFile('file.m'); + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry, undefined); @@ -84,9 +85,9 @@ exports.removeSourceFile = { }, 'should remove 2 fields from the PBXFileReference section': function (test) { proj.addSourceFile('file.m'); - var newFile = proj.removeSourceFile('file.m'), - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var newFile = proj.removeSourceFile('file.m'); + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(66, frsLength); test.ok(!fileRefSection[newFile.fileRef]); @@ -96,50 +97,50 @@ exports.removeSourceFile = { }, 'should remove the PBXFileReference comment correctly': function (test) { proj.addSourceFile('file.m'); - var newFile = proj.removeSourceFile('file.m'), - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var newFile = proj.removeSourceFile('file.m'); + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.ok(!fileRefSection[commentKey]); test.done(); }, 'should remove the PBXFileReference object correctly': function (test) { proj.addSourceFile('file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'), - fileRefSection = proj.pbxFileReferenceSection(), - fileRefEntry = fileRefSection[newFile.fileRef]; + var newFile = proj.removeSourceFile('Plugins/file.m'); + var fileRefSection = proj.pbxFileReferenceSection(); + var fileRefEntry = fileRefSection[newFile.fileRef]; test.ok(!fileRefEntry); test.done(); }, 'should remove from the Plugins PBXGroup group': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'), - plugins = proj.pbxGroupByName('Plugins'); + var newFile = proj.removeSourceFile('Plugins/file.m'); + var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 0); test.done(); }, 'should have the right values for the PBXGroup entry': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'), - plugins = proj.pbxGroupByName('Plugins'), - pluginObj = plugins.children[0]; + var newFile = proj.removeSourceFile('Plugins/file.m'); + var plugins = proj.pbxGroupByName('Plugins'); + var pluginObj = plugins.children[0]; test.ok(!pluginObj); test.done(); }, 'should remove from the PBXSourcesBuildPhase': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'), - sources = proj.pbxSourcesBuildPhaseObj(); + var newFile = proj.removeSourceFile('Plugins/file.m'); + var sources = proj.pbxSourcesBuildPhaseObj(); test.equal(sources.files.length, 2); test.done(); }, 'should have the right values for the Sources entry': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'), - sources = proj.pbxSourcesBuildPhaseObj(), - sourceObj = sources.files[2]; + var newFile = proj.removeSourceFile('Plugins/file.m'); + var sources = proj.pbxSourcesBuildPhaseObj(); + var sourceObj = sources.files[2]; test.ok(!sourceObj); test.done(); diff --git a/test/variantGroup.js b/test/variantGroup.js index 356a232..049aa83 100644 --- a/test/variantGroup.js +++ b/test/variantGroup.js @@ -15,9 +15,10 @@ under the License. */ -var pbx = require('../lib/pbxProject'), - project, - projectHash; +var pbx = require('../lib/pbxProject'); + +var project; +var projectHash; var findChildInGroup = function(obj, target) { var found = false; diff --git a/test/xcode5searchPaths.js b/test/xcode5searchPaths.js index 7cdf46c..cdaae7a 100644 --- a/test/xcode5searchPaths.js +++ b/test/xcode5searchPaths.js @@ -15,12 +15,13 @@ under the License. */ -var xcode5proj = require('./fixtures/library-search-paths') - xcode5projStr = JSON.stringify(xcode5proj), - pbx = require('../lib/pbxProject'), - pbxFile = require('../lib/pbxFile'), - proj = new pbx('.'), - libPoop = { path: 'some/path/poop.a' }; +var xcode5proj = require('./fixtures/library-search-paths'); + +var xcode5projStr = JSON.stringify(xcode5proj); +var pbx = require('../lib/pbxProject'); +var pbxFile = require('../lib/pbxFile'); +var proj = new pbx('.'); +var libPoop = { path: 'some/path/poop.a' }; function cleanHash() { return JSON.parse(xcode5projStr); @@ -35,9 +36,11 @@ var PRODUCT_NAME = '"$(TARGET_NAME)"'; exports.addAndRemoveToFromLibrarySearchPaths = { 'add should add the path to each configuration section':function(test) { - var expected = '"\\"$(SRCROOT)/$(TARGET_NAME)/some/path\\""', - config = proj.pbxXCBuildConfigurationSection(), - ref, lib, refSettings; + var expected = '"\\"$(SRCROOT)/$(TARGET_NAME)/some/path\\""'; + var config = proj.pbxXCBuildConfigurationSection(); + var ref; + var lib; + var refSettings; proj.addToLibrarySearchPaths(libPoop); @@ -57,7 +60,9 @@ exports.addAndRemoveToFromLibrarySearchPaths = { }, 'remove should remove from the path to each configuration section':function(test) { - var config, ref, lib; + var config; + var ref; + var lib; proj.addToLibrarySearchPaths(libPoop); proj.removeFromLibrarySearchPaths(libPoop); From 9c4d408bf6377f388d786a1139352f4785c5b135 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 17:06:38 +0900 Subject: [PATCH 03/22] chore: apply eslint auto fix --- index.js | 2 +- lib/pbxFile.js | 96 ++- lib/pbxProject.js | 1084 ++++++++++++-------------- lib/pbxWriter.js | 144 ++-- test/BuildSettings.js | 10 +- test/FrameworkSearchPaths.js | 18 +- test/HeaderSearchPaths.js | 18 +- test/LibrarySearchPaths.js | 18 +- test/OtherLinkerFlags.js | 10 +- test/addBuildPhase.js | 22 +- test/addFramework.js | 45 +- test/addHeaderFile.js | 10 +- test/addRemovePbxGroup.js | 24 +- test/addResourceFile.js | 30 +- test/addSourceFile.js | 19 +- test/addStaticLibrary.js | 68 +- test/addTarget.js | 38 +- test/addTargetDependency.js | 98 +-- test/addToPbxFileReferenceSection.js | 22 +- test/addWatch2App.js | 20 +- test/addWatch2Extension.js | 26 +- test/addWatchApp.js | 14 +- test/addWatchExtension.js | 16 +- test/addXCConfigurationList.js | 12 +- test/dataModelDocument.js | 18 +- test/group.js | 164 ++-- test/knownRegions.js | 118 +-- test/multipleTargets.js | 119 ++- test/parser/build-config.js | 16 +- test/parser/comments.js | 2 +- test/parser/dotsInNames.js | 6 +- test/parser/file-references.js | 4 +- test/parser/hash.js | 18 +- test/parser/header-search.js | 6 +- test/parser/section-entries.js | 14 +- test/parser/section-split.js | 35 +- test/parser/section.js | 20 +- test/parser/two-sections.js | 8 +- test/parser/with_array.js | 22 +- test/pbxFile.js | 49 +- test/pbxItemByComment.js | 16 +- test/pbxProject.js | 140 ++-- test/pbxTargetByName.js | 10 +- test/pbxWriter.js | 34 +- test/removeFramework.js | 28 +- test/removeHeaderFile.js | 10 +- test/removeResourceFile.js | 12 +- test/removeSourceFile.js | 19 +- test/variantGroup.js | 69 +- test/xcode5searchPaths.js | 16 +- 50 files changed, 1371 insertions(+), 1466 deletions(-) diff --git a/index.js b/index.js index 4fe8416..a590364 100644 --- a/index.js +++ b/index.js @@ -15,4 +15,4 @@ under the License. */ -exports.project = require('./lib/pbxProject') +exports.project = require('./lib/pbxProject'); diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 79d173b..3726b1b 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -25,30 +25,30 @@ var DEFAULT_GROUP = 'Resources'; var DEFAULT_FILETYPE = 'unknown'; var FILETYPE_BY_EXTENSION = { - a: 'archive.ar', - app: 'wrapper.application', - appex: 'wrapper.app-extension', - bundle: 'wrapper.plug-in', - dylib: 'compiled.mach-o.dylib', - framework: 'wrapper.framework', - h: 'sourcecode.c.h', - m: 'sourcecode.c.objc', - markdown: 'text', - mdimporter: 'wrapper.cfbundle', - octest: 'wrapper.cfbundle', - pch: 'sourcecode.c.h', - plist: 'text.plist.xml', - sh: 'text.script.sh', - swift: 'sourcecode.swift', - tbd: 'sourcecode.text-based-dylib-definition', - xcassets: 'folder.assetcatalog', - xcconfig: 'text.xcconfig', - xcdatamodel: 'wrapper.xcdatamodel', - xcodeproj: 'wrapper.pb-project', - xctest: 'wrapper.cfbundle', - xib: 'file.xib', - strings: 'text.plist.strings' - }; + a: 'archive.ar', + app: 'wrapper.application', + appex: 'wrapper.app-extension', + bundle: 'wrapper.plug-in', + dylib: 'compiled.mach-o.dylib', + framework: 'wrapper.framework', + h: 'sourcecode.c.h', + m: 'sourcecode.c.objc', + markdown: 'text', + mdimporter: 'wrapper.cfbundle', + octest: 'wrapper.cfbundle', + pch: 'sourcecode.c.h', + plist: 'text.plist.xml', + sh: 'text.script.sh', + swift: 'sourcecode.swift', + tbd: 'sourcecode.text-based-dylib-definition', + xcassets: 'folder.assetcatalog', + xcconfig: 'text.xcconfig', + xcdatamodel: 'wrapper.xcdatamodel', + xcodeproj: 'wrapper.pb-project', + xctest: 'wrapper.cfbundle', + xib: 'file.xib', + strings: 'text.plist.strings' +}; var GROUP_BY_FILETYPE = { 'archive.ar': 'Frameworks', @@ -78,19 +78,18 @@ var ENCODING_BY_FILETYPE = { 'sourcecode.c.h': 4, 'sourcecode.c.objc': 4, 'sourcecode.swift': 4, - 'text': 4, + text: 4, 'text.plist.xml': 4, 'text.script.sh': 4, 'text.xcconfig': 4, 'text.plist.strings': 4 }; - -function unquoted(text){ - return text == null ? '' : text.replace (/(^")|("$)/g, '') +function unquoted (text) { + return text == null ? '' : text.replace(/(^")|("$)/g, ''); } -function detectType(filePath) { +function detectType (filePath) { var extension = path.extname(filePath).substring(1); var filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; @@ -101,19 +100,18 @@ function detectType(filePath) { return filetype; } -function defaultExtension(fileRef) { - var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ? - fileRef.lastKnownFileType : fileRef.explicitFileType; +function defaultExtension (fileRef) { + var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE + ? fileRef.lastKnownFileType : fileRef.explicitFileType; - for(var extension in FILETYPE_BY_EXTENSION) { - if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) { - if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) ) - return extension; + for (var extension in FILETYPE_BY_EXTENSION) { + if (FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension))) { + if (FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype)) { return extension; } } } } -function defaultEncoding(fileRef) { +function defaultEncoding (fileRef) { var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; var encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; @@ -122,7 +120,7 @@ function defaultEncoding(fileRef) { } } -function detectGroup(fileRef, opt) { +function detectGroup (fileRef, opt) { var extension = path.extname(fileRef.basename).substring(1); var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; var groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; @@ -142,7 +140,7 @@ function detectGroup(fileRef, opt) { return groupName; } -function detectSourcetree(fileRef) { +function detectSourcetree (fileRef) { var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; var sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; @@ -161,7 +159,7 @@ function detectSourcetree(fileRef) { return sourcetree; } -function defaultPath(fileRef, filePath) { +function defaultPath (fileRef, filePath) { var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; var defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; @@ -176,7 +174,7 @@ function defaultPath(fileRef, filePath) { return filePath; } -function defaultGroup(fileRef) { +function defaultGroup (fileRef) { var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType]; if (!groupName) { @@ -186,7 +184,7 @@ function defaultGroup(fileRef) { return defaultGroup; } -function pbxFile(filepath, opt) { +function pbxFile (filepath, opt) { var opt = opt || {}; this.basename = path.basename(filepath); @@ -215,21 +213,17 @@ function pbxFile(filepath, opt) { this.sourceTree = opt.sourceTree || detectSourcetree(this); this.includeInIndex = 0; - if (opt.weak && opt.weak === true) - this.settings = { ATTRIBUTES: ['Weak'] }; + if (opt.weak && opt.weak === true) { this.settings = { ATTRIBUTES: ['Weak'] }; } if (opt.compilerFlags) { - if (!this.settings) - this.settings = {}; + if (!this.settings) { this.settings = {}; } this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags); } if (opt.embed && opt.sign) { - if (!this.settings) - this.settings = {}; - if (!this.settings.ATTRIBUTES) - this.settings.ATTRIBUTES = []; - this.settings.ATTRIBUTES.push('CodeSignOnCopy'); + if (!this.settings) { this.settings = {}; } + if (!this.settings.ATTRIBUTES) { this.settings.ATTRIBUTES = []; } + this.settings.ATTRIBUTES.push('CodeSignOnCopy'); } } diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 4833913..899df16 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -29,24 +29,23 @@ var parser = require('./parser/pbxproj'); var plist = require('simple-plist'); var COMMENT_KEY = /_comment$/; -function pbxProject(filename) { - if (!(this instanceof pbxProject)) - return new pbxProject(filename); +function pbxProject (filename) { + if (!(this instanceof pbxProject)) { return new pbxProject(filename); } - this.filepath = path.resolve(filename) + this.filepath = path.resolve(filename); } -util.inherits(pbxProject, EventEmitter) +util.inherits(pbxProject, EventEmitter); -pbxProject.prototype.parse = function(cb) { - var worker = fork(__dirname + '/parseJob.js', [this.filepath]) +pbxProject.prototype.parse = function (cb) { + var worker = fork(__dirname + '/parseJob.js', [this.filepath]); - worker.on('message', function(msg) { + worker.on('message', function (msg) { if (msg.name == 'SyntaxError' || msg.code) { this.emit('error', msg); } else { this.hash = msg; - this.emit('end', null, msg) + this.emit('end', null, msg); } }.bind(this)); @@ -56,51 +55,51 @@ pbxProject.prototype.parse = function(cb) { } return this; -} +}; -pbxProject.prototype.parseSync = function() { +pbxProject.prototype.parseSync = function () { var file_contents = fs.readFileSync(this.filepath, 'utf-8'); this.hash = parser.parse(file_contents); return this; -} +}; -pbxProject.prototype.writeSync = function(options) { +pbxProject.prototype.writeSync = function (options) { this.writer = new pbxWriter(this.hash, options); return this.writer.writeSync(); -} +}; -pbxProject.prototype.allUuids = function() { +pbxProject.prototype.allUuids = function () { var sections = this.hash.project.objects; var uuids = []; var section; for (key in sections) { - section = sections[key] - uuids = uuids.concat(Object.keys(section)) + section = sections[key]; + uuids = uuids.concat(Object.keys(section)); } - uuids = uuids.filter(function(str) { + uuids = uuids.filter(function (str) { return !COMMENT_KEY.test(str) && str.length == 24; }); return uuids; -} +}; -pbxProject.prototype.generateUuid = function() { +pbxProject.prototype.generateUuid = function () { var id = uuid.v4() .replace(/-/g, '') .substr(0, 24) - .toUpperCase() + .toUpperCase(); if (this.allUuids().indexOf(id) >= 0) { return this.generateUuid(); } else { return id; } -} +}; -pbxProject.prototype.addPluginFile = function(path, opt) { +pbxProject.prototype.addPluginFile = function (path, opt) { var file = new pbxFile(path, opt); file.plugin = true; // durr @@ -111,23 +110,23 @@ pbxProject.prototype.addPluginFile = function(path, opt) { file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPluginsPbxGroup(file); // PBXGroup + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPluginsPbxGroup(file); // PBXGroup return file; -} +}; -pbxProject.prototype.removePluginFile = function(path, opt) { +pbxProject.prototype.removePluginFile = function (path, opt) { var file = new pbxFile(path, opt); correctForPluginsPath(file, this); - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - this.removeFromPluginsPbxGroup(file); // PBXGroup + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPluginsPbxGroup(file); // PBXGroup return file; -} +}; -pbxProject.prototype.addProductFile = function(targetPath, opt) { +pbxProject.prototype.addProductFile = function (targetPath, opt) { var file = new pbxFile(targetPath, opt); file.includeInIndex = 0; @@ -138,18 +137,18 @@ pbxProject.prototype.addProductFile = function(targetPath, opt) { file.path = file.basename; this.addToPbxFileReferenceSection(file); - this.addToProductsPbxGroup(file); // PBXGroup + this.addToProductsPbxGroup(file); // PBXGroup return file; -} +}; -pbxProject.prototype.removeProductFile = function(path, opt) { +pbxProject.prototype.removeProductFile = function (path, opt) { var file = new pbxFile(path, opt); - this.removeFromProductsPbxGroup(file); // PBXGroup + this.removeFromProductsPbxGroup(file); // PBXGroup return file; -} +}; /** * @@ -162,8 +161,7 @@ pbxProject.prototype.addSourceFile = function (path, opt, group) { var file; if (group) { file = this.addFile(path, group, opt); - } - else { + } else { file = this.addPluginFile(path, opt); } @@ -172,11 +170,11 @@ pbxProject.prototype.addSourceFile = function (path, opt, group) { file.target = opt ? opt.target : undefined; file.uuid = this.generateUuid(); - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase return file; -} +}; /** * @@ -189,16 +187,15 @@ pbxProject.prototype.removeSourceFile = function (path, opt, group) { var file; if (group) { file = this.removeFile(path, group, opt); - } - else { + } else { file = this.removePluginFile(path, opt); } file.target = opt ? opt.target : undefined; - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase return file; -} +}; /** * @@ -210,11 +207,10 @@ pbxProject.prototype.removeSourceFile = function (path, opt, group) { pbxProject.prototype.addHeaderFile = function (path, opt, group) { if (group) { return this.addFile(path, group, opt); - } - else { + } else { return this.addPluginFile(path, opt); } -} +}; /** * @@ -226,11 +222,10 @@ pbxProject.prototype.addHeaderFile = function (path, opt, group) { pbxProject.prototype.removeHeaderFile = function (path, opt, group) { if (group) { return this.removeFile(path, group, opt); - } - else { + } else { return this.removePluginFile(path, opt); } -} +}; /** * @@ -239,7 +234,7 @@ pbxProject.prototype.removeHeaderFile = function (path, opt, group) { * @param group {String} group key * @returns {Object} file; see pbxFile */ -pbxProject.prototype.addResourceFile = function(path, opt, group) { +pbxProject.prototype.addResourceFile = function (path, opt, group) { opt = opt || {}; var file; @@ -261,28 +256,25 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) { } if (!opt.variantGroup) { - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase } if (!opt.plugin) { - this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxFileReferenceSection(file); // PBXFileReference if (group) { if (this.getPBXGroupByKey(group)) { - this.addToPbxGroup(file, group); //Group other than Resources (i.e. 'splash') - } - else if (this.getPBXVariantGroupByKey(group)) { - this.addToPbxVariantGroup(file, group); // PBXVariantGroup + this.addToPbxGroup(file, group); // Group other than Resources (i.e. 'splash') + } else if (this.getPBXVariantGroupByKey(group)) { + this.addToPbxVariantGroup(file, group); // PBXVariantGroup } + } else { + this.addToResourcesPbxGroup(file); // PBXGroup } - else { - this.addToResourcesPbxGroup(file); // PBXGroup - } - } return file; -} +}; /** * @@ -291,37 +283,35 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) { * @param group {String} group key * @returns {Object} file; see pbxFile */ -pbxProject.prototype.removeResourceFile = function(path, opt, group) { +pbxProject.prototype.removeResourceFile = function (path, opt, group) { var file = new pbxFile(path, opt); file.target = opt ? opt.target : undefined; correctForResourcesPath(file, this); - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference if (group) { if (this.getPBXGroupByKey(group)) { - this.removeFromPbxGroup(file, group); //Group other than Resources (i.e. 'splash') + this.removeFromPbxGroup(file, group); // Group other than Resources (i.e. 'splash') + } else if (this.getPBXVariantGroupByKey(group)) { + this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup } - else if (this.getPBXVariantGroupByKey(group)) { - this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup - } - } - else { - this.removeFromResourcesPbxGroup(file); // PBXGroup + } else { + this.removeFromResourcesPbxGroup(file); // PBXGroup } - this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase + this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase return file; -} +}; -pbxProject.prototype.addFramework = function(fpath, opt) { +pbxProject.prototype.addFramework = function (fpath, opt) { var customFramework = opt && opt.customFramework == true; - var link = !opt || (opt.link == undefined || opt.link); //defaults to true if not specified - var embed = opt && opt.embed; //defaults to false if not specified + var link = !opt || (opt.link == undefined || opt.link); // defaults to true if not specified + var embed = opt && opt.embed; // defaults to false if not specified if (opt) { - delete opt.embed; + delete opt.embed; } var file = new pbxFile(fpath, opt); @@ -332,50 +322,50 @@ pbxProject.prototype.addFramework = function(fpath, opt) { if (this.hasFile(file.path)) return false; - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToFrameworksPbxGroup(file); // PBXGroup + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToFrameworksPbxGroup(file); // PBXGroup if (link) { - this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase } if (customFramework) { this.addToFrameworkSearchPaths(file); if (embed) { - opt.embed = embed; - var embeddedFile = new pbxFile(fpath, opt); + opt.embed = embed; + var embeddedFile = new pbxFile(fpath, opt); - embeddedFile.uuid = this.generateUuid(); - embeddedFile.fileRef = file.fileRef; + embeddedFile.uuid = this.generateUuid(); + embeddedFile.fileRef = file.fileRef; - //keeping a separate PBXBuildFile entry for Embed Frameworks - this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile + // keeping a separate PBXBuildFile entry for Embed Frameworks + this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile - this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase + this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase - return embeddedFile; + return embeddedFile; } } return file; -} +}; -pbxProject.prototype.removeFramework = function(fpath, opt) { +pbxProject.prototype.removeFramework = function (fpath, opt) { var embed = opt && opt.embed; if (opt) { - delete opt.embed; + delete opt.embed; } var file = new pbxFile(fpath, opt); file.target = opt ? opt.target : undefined; - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - this.removeFromFrameworksPbxGroup(file); // PBXGroup - this.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromFrameworksPbxGroup(file); // PBXGroup + this.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase if (opt && opt.customFramework) { this.removeFromFrameworkSearchPaths(file); @@ -387,14 +377,13 @@ pbxProject.prototype.removeFramework = function(fpath, opt) { embeddedFile.fileRef = file.fileRef; - this.removeFromPbxBuildFileSection(embeddedFile); // PBXBuildFile + this.removeFromPbxBuildFileSection(embeddedFile); // PBXBuildFile this.removeFromPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase return file; -} - +}; -pbxProject.prototype.addCopyfile = function(fpath, opt) { +pbxProject.prototype.addCopyfile = function (fpath, opt) { var file = new pbxFile(fpath, opt); // catch duplicates @@ -405,34 +394,34 @@ pbxProject.prototype.addCopyfile = function(fpath, opt) { file.fileRef = file.uuid = this.generateUuid(); file.target = opt ? opt.target : undefined; - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxCopyfilesBuildPhase(file); // PBXCopyFilesBuildPhase + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxCopyfilesBuildPhase(file); // PBXCopyFilesBuildPhase return file; -} +}; -pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function(target) { +pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function (target) { return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', target); -} +}; -pbxProject.prototype.addToPbxCopyfilesBuildPhase = function(file) { +pbxProject.prototype.addToPbxCopyfilesBuildPhase = function (file) { var sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target); sources.files.push(pbxBuildPhaseObj(file)); -} +}; -pbxProject.prototype.removeCopyfile = function(fpath, opt) { +pbxProject.prototype.removeCopyfile = function (fpath, opt) { var file = new pbxFile(fpath, opt); file.target = opt ? opt.target : undefined; - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - this.removeFromPbxCopyfilesBuildPhase(file); // PBXFrameworksBuildPhase + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPbxCopyfilesBuildPhase(file); // PBXFrameworksBuildPhase return file; -} +}; -pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function(file) { +pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function (file) { var sources = this.pbxCopyfilesBuildPhaseObj(file.target); for (i in sources.files) { if (sources.files[i].comment == longComment(file)) { @@ -440,9 +429,9 @@ pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function(file) { break; } } -} +}; -pbxProject.prototype.addStaticLibrary = function(path, opt) { +pbxProject.prototype.addStaticLibrary = function (path, opt) { opt = opt || {}; var file; @@ -460,25 +449,25 @@ pbxProject.prototype.addStaticLibrary = function(path, opt) { if (!opt.plugin) { file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxFileReferenceSection(file); // PBXFileReference } - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase - this.addToLibrarySearchPaths(file); // make sure it gets built! + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + this.addToLibrarySearchPaths(file); // make sure it gets built! return file; -} +}; // helper addition functions -pbxProject.prototype.addToPbxBuildFileSection = function(file) { - var commentKey = f("%s_comment", file.uuid); +pbxProject.prototype.addToPbxBuildFileSection = function (file) { + var commentKey = f('%s_comment', file.uuid); this.pbxBuildFileSection()[file.uuid] = pbxBuildFileObj(file); this.pbxBuildFileSection()[commentKey] = pbxBuildFileComment(file); -} +}; -pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { +pbxProject.prototype.removeFromPbxBuildFileSection = function (file) { var uuid; for (uuid in this.pbxBuildFileSection()) { @@ -486,23 +475,23 @@ pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { file.uuid = uuid; delete this.pbxBuildFileSection()[uuid]; - var commentKey = f("%s_comment", uuid); + var commentKey = f('%s_comment', uuid); delete this.pbxBuildFileSection()[commentKey]; } } -} +}; -pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTree) { - var groups = this.hash.project.objects['PBXGroup']; +pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceTree) { + var groups = this.hash.project.objects.PBXGroup; var pbxGroupUuid = this.generateUuid(); - var commentKey = f("%s_comment", pbxGroupUuid); + var commentKey = f('%s_comment', pbxGroupUuid); var pbxGroup = { isa: 'PBXGroup', children: [], name: name, path: path, - sourceTree: sourceTree ? sourceTree : '""' + sourceTree: sourceTree || '""' }; var fileReferenceSection = this.pbxFileReferenceSection(); @@ -520,7 +509,7 @@ pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTr for (var index = 0; index < filePathsArray.length; index++) { var filePath = filePathsArray[index]; - var filePathQuoted = "\"" + filePath + "\""; + var filePathQuoted = '"' + filePath + '"'; if (filePathToReference[filePath]) { pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath])); continue; @@ -532,8 +521,8 @@ pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTr var file = new pbxFile(filePath); file.uuid = this.generateUuid(); file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxBuildFileSection(file); // PBXBuildFile pbxGroup.children.push(pbxGroupChild(file)); } @@ -543,10 +532,10 @@ pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTr } return { uuid: pbxGroupUuid, pbxGroup: pbxGroup }; -} +}; pbxProject.prototype.removePbxGroup = function (groupName) { - var section = this.hash.project.objects['PBXGroup']; + var section = this.hash.project.objects.PBXGroup; var key; var itemKey; @@ -559,34 +548,32 @@ pbxProject.prototype.removePbxGroup = function (groupName) { delete section[itemKey]; } } -} - -pbxProject.prototype.addToPbxProjectSection = function(target) { +}; +pbxProject.prototype.addToPbxProjectSection = function (target) { var newTarget = { - value: target.uuid, - comment: pbxNativeTargetComment(target.pbxNativeTarget) - }; + value: target.uuid, + comment: pbxNativeTargetComment(target.pbxNativeTarget) + }; - this.pbxProjectSection()[this.getFirstProject()['uuid']]['targets'].push(newTarget); -} + this.pbxProjectSection()[this.getFirstProject().uuid].targets.push(newTarget); +}; -pbxProject.prototype.addToPbxNativeTargetSection = function(target) { - var commentKey = f("%s_comment", target.uuid); +pbxProject.prototype.addToPbxNativeTargetSection = function (target) { + var commentKey = f('%s_comment', target.uuid); this.pbxNativeTargetSection()[target.uuid] = target.pbxNativeTarget; this.pbxNativeTargetSection()[commentKey] = target.pbxNativeTarget.name; -} +}; -pbxProject.prototype.addToPbxFileReferenceSection = function(file) { - var commentKey = f("%s_comment", file.fileRef); +pbxProject.prototype.addToPbxFileReferenceSection = function (file) { + var commentKey = f('%s_comment', file.fileRef); this.pbxFileReferenceSection()[file.fileRef] = pbxFileReferenceObj(file); this.pbxFileReferenceSection()[commentKey] = pbxFileReferenceComment(file); -} - -pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) { +}; +pbxProject.prototype.removeFromPbxFileReferenceSection = function (file) { var i; var refObj = pbxFileReferenceObj(file); for (i in this.pbxFileReferenceSection()) { @@ -599,20 +586,20 @@ pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) { break; } } - var commentKey = f("%s_comment", file.fileRef); + var commentKey = f('%s_comment', file.fileRef); if (this.pbxFileReferenceSection()[commentKey] != undefined) { delete this.pbxFileReferenceSection()[commentKey]; } return file; -} +}; -pbxProject.prototype.addToXcVersionGroupSection = function(file) { +pbxProject.prototype.addToXcVersionGroupSection = function (file) { if (!file.models || !file.currentModel) { - throw new Error("Cannot create a XCVersionGroup section from not a data model document file"); + throw new Error('Cannot create a XCVersionGroup section from not a data model document file'); } - var commentKey = f("%s_comment", file.fileRef); + var commentKey = f('%s_comment', file.fileRef); if (!this.xcVersionGroupSection()[file.fileRef]) { this.xcVersionGroupSection()[file.fileRef] = { @@ -626,18 +613,18 @@ pbxProject.prototype.addToXcVersionGroupSection = function(file) { }; this.xcVersionGroupSection()[commentKey] = path.basename(file.path); } -} +}; -pbxProject.prototype.addToPluginsPbxGroup = function(file) { +pbxProject.prototype.addToPluginsPbxGroup = function (file) { var pluginsGroup = this.pbxGroupByName('Plugins'); if (!pluginsGroup) { this.addPbxGroup([file.path], 'Plugins'); } else { pluginsGroup.children.push(pbxGroupChild(file)); } -} +}; -pbxProject.prototype.removeFromPluginsPbxGroup = function(file) { +pbxProject.prototype.removeFromPluginsPbxGroup = function (file) { if (!this.pbxGroupByName('Plugins')) { return null; } @@ -650,18 +637,18 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function(file) { break; } } -} +}; -pbxProject.prototype.addToResourcesPbxGroup = function(file) { +pbxProject.prototype.addToResourcesPbxGroup = function (file) { var pluginsGroup = this.pbxGroupByName('Resources'); if (!pluginsGroup) { this.addPbxGroup([file.path], 'Resources'); } else { pluginsGroup.children.push(pbxGroupChild(file)); } -} +}; -pbxProject.prototype.removeFromResourcesPbxGroup = function(file) { +pbxProject.prototype.removeFromResourcesPbxGroup = function (file) { if (!this.pbxGroupByName('Resources')) { return null; } @@ -674,18 +661,18 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function(file) { break; } } -} +}; -pbxProject.prototype.addToFrameworksPbxGroup = function(file) { +pbxProject.prototype.addToFrameworksPbxGroup = function (file) { var pluginsGroup = this.pbxGroupByName('Frameworks'); if (!pluginsGroup) { this.addPbxGroup([file.path], 'Frameworks'); } else { pluginsGroup.children.push(pbxGroupChild(file)); } -} +}; -pbxProject.prototype.removeFromFrameworksPbxGroup = function(file) { +pbxProject.prototype.removeFromFrameworksPbxGroup = function (file) { if (!this.pbxGroupByName('Frameworks')) { return null; } @@ -698,14 +685,14 @@ pbxProject.prototype.removeFromFrameworksPbxGroup = function(file) { break; } } -} +}; pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) { var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); if (sources) { sources.files.push(pbxBuildPhaseObj(file)); } -} +}; pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); @@ -718,18 +705,18 @@ pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { } sources.files = files; } -} +}; -pbxProject.prototype.addToProductsPbxGroup = function(file) { +pbxProject.prototype.addToProductsPbxGroup = function (file) { var productsGroup = this.pbxGroupByName('Products'); if (!productsGroup) { this.addPbxGroup([file.path], 'Products'); } else { productsGroup.children.push(pbxGroupChild(file)); } -} +}; -pbxProject.prototype.removeFromProductsPbxGroup = function(file) { +pbxProject.prototype.removeFromProductsPbxGroup = function (file) { if (!this.pbxGroupByName('Products')) { return null; } @@ -742,14 +729,14 @@ pbxProject.prototype.removeFromProductsPbxGroup = function(file) { break; } } -} +}; -pbxProject.prototype.addToPbxSourcesBuildPhase = function(file) { +pbxProject.prototype.addToPbxSourcesBuildPhase = function (file) { var sources = this.pbxSourcesBuildPhaseObj(file.target); sources.files.push(pbxBuildPhaseObj(file)); -} +}; -pbxProject.prototype.removeFromPbxSourcesBuildPhase = function(file) { +pbxProject.prototype.removeFromPbxSourcesBuildPhase = function (file) { var sources = this.pbxSourcesBuildPhaseObj(file.target); var i; for (i in sources.files) { @@ -758,14 +745,14 @@ pbxProject.prototype.removeFromPbxSourcesBuildPhase = function(file) { break; } } -} +}; -pbxProject.prototype.addToPbxResourcesBuildPhase = function(file) { +pbxProject.prototype.addToPbxResourcesBuildPhase = function (file) { var sources = this.pbxResourcesBuildPhaseObj(file.target); sources.files.push(pbxBuildPhaseObj(file)); -} +}; -pbxProject.prototype.removeFromPbxResourcesBuildPhase = function(file) { +pbxProject.prototype.removeFromPbxResourcesBuildPhase = function (file) { var sources = this.pbxResourcesBuildPhaseObj(file.target); var i; @@ -775,14 +762,14 @@ pbxProject.prototype.removeFromPbxResourcesBuildPhase = function(file) { break; } } -} +}; -pbxProject.prototype.addToPbxFrameworksBuildPhase = function(file) { +pbxProject.prototype.addToPbxFrameworksBuildPhase = function (file) { var sources = this.pbxFrameworksBuildPhaseObj(file.target); sources.files.push(pbxBuildPhaseObj(file)); -} +}; -pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) { +pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function (file) { var sources = this.pbxFrameworksBuildPhaseObj(file.target); for (i in sources.files) { if (sources.files[i].comment == longComment(file)) { @@ -790,13 +777,13 @@ pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) { break; } } -} +}; -pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray, defaultConfigurationName, comment) { +pbxProject.prototype.addXCConfigurationList = function (configurationObjectsArray, defaultConfigurationName, comment) { var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(); var pbxXCConfigurationListSection = this.pbxXCConfigurationList(); var xcConfigurationListUuid = this.generateUuid(); - var commentKey = f("%s_comment", xcConfigurationListUuid); + var commentKey = f('%s_comment', xcConfigurationListUuid); var xcConfigurationList = { isa: 'XCConfigurationList', @@ -808,7 +795,7 @@ pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray for (var index = 0; index < configurationObjectsArray.length; index++) { var configuration = configurationObjectsArray[index]; var configurationUuid = this.generateUuid(); - var configurationCommentKey = f("%s_comment", configurationUuid); + var configurationCommentKey = f('%s_comment', configurationUuid); pbxBuildConfigurationSection[configurationUuid] = configuration; pbxBuildConfigurationSection[configurationCommentKey] = configuration.name; @@ -821,22 +808,19 @@ pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray } return { uuid: xcConfigurationListUuid, xcConfigurationList: xcConfigurationList }; -} +}; -pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { - if (!target) - return undefined; +pbxProject.prototype.addTargetDependency = function (target, dependencyTargets) { + if (!target) { return undefined; } var nativeTargets = this.pbxNativeTargetSection(); - if (typeof nativeTargets[target] == "undefined") - throw new Error("Invalid target: " + target); + if (typeof nativeTargets[target] === 'undefined') { throw new Error('Invalid target: ' + target); } for (var index = 0; index < dependencyTargets.length; index++) { var dependencyTarget = dependencyTargets[index]; - if (typeof nativeTargets[dependencyTarget] == "undefined") - throw new Error("Invalid target: " + dependencyTarget); - } + if (typeof nativeTargets[dependencyTarget] === 'undefined') { throw new Error('Invalid target: ' + dependencyTarget); } + } var pbxTargetDependency = 'PBXTargetDependency'; var pbxContainerItemProxy = 'PBXContainerItemProxy'; @@ -845,16 +829,16 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { for (var index = 0; index < dependencyTargets.length; index++) { var dependencyTargetUuid = dependencyTargets[index]; - var dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid); + var dependencyTargetCommentKey = f('%s_comment', dependencyTargetUuid); var targetDependencyUuid = this.generateUuid(); - var targetDependencyCommentKey = f("%s_comment", targetDependencyUuid); + var targetDependencyCommentKey = f('%s_comment', targetDependencyUuid); var itemProxyUuid = this.generateUuid(); - var itemProxyCommentKey = f("%s_comment", itemProxyUuid); + var itemProxyCommentKey = f('%s_comment', itemProxyUuid); var itemProxy = { isa: pbxContainerItemProxy, - containerPortal: this.hash.project['rootObject'], - containerPortal_comment: this.hash.project['rootObject_comment'], + containerPortal: this.hash.project.rootObject, + containerPortal_comment: this.hash.project.rootObject_comment, proxyType: 1, remoteGlobalIDString: dependencyTargetUuid, remoteInfo: nativeTargets[dependencyTargetUuid].name @@ -873,20 +857,20 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { pbxContainerItemProxySection[itemProxyCommentKey] = pbxContainerItemProxy; pbxTargetDependencySection[targetDependencyUuid] = targetDependency; pbxTargetDependencySection[targetDependencyCommentKey] = pbxTargetDependency; - nativeTargets[target].dependencies.push({ value: targetDependencyUuid, comment: pbxTargetDependency }) + nativeTargets[target].dependencies.push({ value: targetDependencyUuid, comment: pbxTargetDependency }); } } return { uuid: target, target: nativeTargets[target] }; -} +}; -pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) { +pbxProject.prototype.addBuildPhase = function (filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) { var buildPhaseSection; var fileReferenceSection = this.pbxFileReferenceSection(); var buildFileSection = this.pbxBuildFileSection(); var buildPhaseUuid = this.generateUuid(); var buildPhaseTargetUuid = target || this.getFirstTarget().uuid; - var commentKey = f("%s_comment", buildPhaseUuid); + var commentKey = f('%s_comment', buildPhaseUuid); var buildPhase = { isa: buildPhaseType, @@ -900,7 +884,7 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co if (buildPhaseType === 'PBXCopyFilesBuildPhase') { buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment); } else if (buildPhaseType === 'PBXShellScriptBuildPhase') { - buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment) + buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment); } if (!this.hash.project.objects[buildPhaseType]) { @@ -912,15 +896,13 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co this.hash.project.objects[buildPhaseType][commentKey] = comment; } - if (this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases']) { - this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases'].push({ + if (this.hash.project.objects.PBXNativeTarget[buildPhaseTargetUuid].buildPhases) { + this.hash.project.objects.PBXNativeTarget[buildPhaseTargetUuid].buildPhases.push({ value: buildPhaseUuid, comment: comment - }) - + }); } - for (var key in buildFileSection) { // only look for comments if (!COMMENT_KEY.test(key)) continue; @@ -938,7 +920,7 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co for (var index = 0; index < filePathsArray.length; index++) { var filePath = filePathsArray[index]; - var filePathQuoted = "\"" + filePath + "\""; + var filePathQuoted = '"' + filePath + '"'; var file = new pbxFile(filePath); if (filePathToBuildFile[filePath]) { @@ -951,8 +933,8 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co file.uuid = this.generateUuid(); file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxBuildFileSection(file); // PBXBuildFile buildPhase.files.push(pbxBuildPhaseObj(file)); } @@ -962,42 +944,42 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co } return { uuid: buildPhaseUuid, buildPhase: buildPhase }; -} +}; // helper access functions -pbxProject.prototype.pbxProjectSection = function() { - return this.hash.project.objects['PBXProject']; -} -pbxProject.prototype.pbxBuildFileSection = function() { - return this.hash.project.objects['PBXBuildFile']; -} +pbxProject.prototype.pbxProjectSection = function () { + return this.hash.project.objects.PBXProject; +}; +pbxProject.prototype.pbxBuildFileSection = function () { + return this.hash.project.objects.PBXBuildFile; +}; -pbxProject.prototype.pbxXCBuildConfigurationSection = function() { - return this.hash.project.objects['XCBuildConfiguration']; -} +pbxProject.prototype.pbxXCBuildConfigurationSection = function () { + return this.hash.project.objects.XCBuildConfiguration; +}; -pbxProject.prototype.pbxFileReferenceSection = function() { - return this.hash.project.objects['PBXFileReference']; -} +pbxProject.prototype.pbxFileReferenceSection = function () { + return this.hash.project.objects.PBXFileReference; +}; -pbxProject.prototype.pbxNativeTargetSection = function() { - return this.hash.project.objects['PBXNativeTarget']; -} +pbxProject.prototype.pbxNativeTargetSection = function () { + return this.hash.project.objects.PBXNativeTarget; +}; pbxProject.prototype.xcVersionGroupSection = function () { - if (typeof this.hash.project.objects['XCVersionGroup'] !== 'object') { - this.hash.project.objects['XCVersionGroup'] = {}; + if (typeof this.hash.project.objects.XCVersionGroup !== 'object') { + this.hash.project.objects.XCVersionGroup = {}; } - return this.hash.project.objects['XCVersionGroup']; -} + return this.hash.project.objects.XCVersionGroup; +}; -pbxProject.prototype.pbxXCConfigurationList = function() { - return this.hash.project.objects['XCConfigurationList']; -} +pbxProject.prototype.pbxXCConfigurationList = function () { + return this.hash.project.objects.XCConfigurationList; +}; -pbxProject.prototype.pbxGroupByName = function(name) { - var groups = this.hash.project.objects['PBXGroup']; +pbxProject.prototype.pbxGroupByName = function (name) { + var groups = this.hash.project.objects.PBXGroup; var key; var groupKey; @@ -1012,14 +994,14 @@ pbxProject.prototype.pbxGroupByName = function(name) { } return null; -} +}; -pbxProject.prototype.pbxTargetByName = function(name) { +pbxProject.prototype.pbxTargetByName = function (name) { return this.pbxItemByComment(name, 'PBXNativeTarget'); -} +}; -pbxProject.prototype.findTargetKey = function(name) { - var targets = this.hash.project.objects['PBXNativeTarget']; +pbxProject.prototype.findTargetKey = function (name) { + var targets = this.hash.project.objects.PBXNativeTarget; for (var key in targets) { // only look for comments @@ -1032,9 +1014,9 @@ pbxProject.prototype.findTargetKey = function(name) { } return null; -} +}; -pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) { +pbxProject.prototype.pbxItemByComment = function (name, pbxSectionName) { var section = this.hash.project.objects[pbxSectionName]; var key; var itemKey; @@ -1050,45 +1032,40 @@ pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) { } return null; -} +}; -pbxProject.prototype.pbxSourcesBuildPhaseObj = function(target) { +pbxProject.prototype.pbxSourcesBuildPhaseObj = function (target) { return this.buildPhaseObject('PBXSourcesBuildPhase', 'Sources', target); -} +}; -pbxProject.prototype.pbxResourcesBuildPhaseObj = function(target) { +pbxProject.prototype.pbxResourcesBuildPhaseObj = function (target) { return this.buildPhaseObject('PBXResourcesBuildPhase', 'Resources', target); -} +}; -pbxProject.prototype.pbxFrameworksBuildPhaseObj = function(target) { +pbxProject.prototype.pbxFrameworksBuildPhaseObj = function (target) { return this.buildPhaseObject('PBXFrameworksBuildPhase', 'Frameworks', target); -} +}; pbxProject.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) { return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks', target); }; // Find Build Phase from group/target -pbxProject.prototype.buildPhase = function(group, target) { - - if (!target) - return undefined; +pbxProject.prototype.buildPhase = function (group, target) { + if (!target) { return undefined; } var nativeTargets = this.pbxNativeTargetSection(); - if (typeof nativeTargets[target] == "undefined") - throw new Error("Invalid target: " + target); + if (typeof nativeTargets[target] === 'undefined') { throw new Error('Invalid target: ' + target); } var nativeTarget = nativeTargets[target]; var buildPhases = nativeTarget.buildPhases; - for(var i in buildPhases) - { + for (var i in buildPhases) { var buildPhase = buildPhases[i]; - if (buildPhase.comment==group) - return buildPhase.value + "_comment"; - } + if (buildPhase.comment == group) { return buildPhase.value + '_comment'; } } +}; -pbxProject.prototype.buildPhaseObject = function(name, group, target) { +pbxProject.prototype.buildPhaseObject = function (name, group, target) { var section = this.hash.project.objects[name]; var obj; var sectionKey; @@ -1096,47 +1073,45 @@ pbxProject.prototype.buildPhaseObject = function(name, group, target) { var buildPhase = this.buildPhase(group, target); for (key in section) { - // only look for comments if (!COMMENT_KEY.test(key)) continue; // select the proper buildPhase - if (buildPhase && buildPhase!=key) - continue; + if (buildPhase && buildPhase != key) { continue; } if (section[key] == group) { sectionKey = key.split(COMMENT_KEY)[0]; return section[sectionKey]; } } return null; -} +}; -pbxProject.prototype.addBuildProperty = function(prop, value, build_name) { +pbxProject.prototype.addBuildProperty = function (prop, value, build_name) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var key; var configuration; - for (key in configurations){ + for (key in configurations) { configuration = configurations[key]; - if (!build_name || configuration.name === build_name){ + if (!build_name || configuration.name === build_name) { configuration.buildSettings[prop] = value; } } -} +}; -pbxProject.prototype.removeBuildProperty = function(prop, build_name) { +pbxProject.prototype.removeBuildProperty = function (prop, build_name) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var key; var configuration; - for (key in configurations){ + for (key in configurations) { configuration = configurations[key]; if (configuration.buildSettings[prop] && - !build_name || configuration.name === build_name){ + !build_name || configuration.name === build_name) { delete configuration.buildSettings[prop]; } } -} +}; /** * @@ -1144,23 +1119,23 @@ pbxProject.prototype.removeBuildProperty = function(prop, build_name) { * @param value {String|Array|Object|Number|Boolean} * @param build {String} Release or Debug */ -pbxProject.prototype.updateBuildProperty = function(prop, value, build) { +pbxProject.prototype.updateBuildProperty = function (prop, value, build) { var configs = this.pbxXCBuildConfigurationSection(); for (var configName in configs) { if (!COMMENT_KEY.test(configName)) { var config = configs[configName]; - if ( (build && config.name === build) || (!build) ) { + if ((build && config.name === build) || (!build)) { config.buildSettings[prop] = value; } } } -} +}; -pbxProject.prototype.updateProductName = function(name) { +pbxProject.prototype.updateProductName = function (name) { this.updateBuildProperty('PRODUCT_NAME', '"' + name + '"'); -} +}; -pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) { +pbxProject.prototype.removeFromFrameworkSearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var INHERITED = '"$(inherited)"'; var SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS'; @@ -1172,24 +1147,23 @@ pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } searchPaths = buildSettings[SEARCH_PATHS]; if (searchPaths && Array.isArray(searchPaths)) { - var matches = searchPaths.filter(function(p) { + var matches = searchPaths.filter(function (p) { return p.indexOf(new_path) > -1; }); - matches.forEach(function(m) { + matches.forEach(function (m) { var idx = searchPaths.indexOf(m); searchPaths.splice(idx, 1); }); } } -} +}; -pbxProject.prototype.addToFrameworkSearchPaths = function(file) { +pbxProject.prototype.addToFrameworkSearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var INHERITED = '"$(inherited)"'; var config; @@ -1199,19 +1173,18 @@ pbxProject.prototype.addToFrameworkSearchPaths = function(file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } - if (!buildSettings['FRAMEWORK_SEARCH_PATHS'] - || buildSettings['FRAMEWORK_SEARCH_PATHS'] === INHERITED) { - buildSettings['FRAMEWORK_SEARCH_PATHS'] = [INHERITED]; + if (!buildSettings.FRAMEWORK_SEARCH_PATHS || + buildSettings.FRAMEWORK_SEARCH_PATHS === INHERITED) { + buildSettings.FRAMEWORK_SEARCH_PATHS = [INHERITED]; } - buildSettings['FRAMEWORK_SEARCH_PATHS'].push(searchPathForFile(file, this)); + buildSettings.FRAMEWORK_SEARCH_PATHS.push(searchPathForFile(file, this)); } -} +}; -pbxProject.prototype.removeFromLibrarySearchPaths = function(file) { +pbxProject.prototype.removeFromLibrarySearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var INHERITED = '"$(inherited)"'; var SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS'; @@ -1223,25 +1196,23 @@ pbxProject.prototype.removeFromLibrarySearchPaths = function(file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } searchPaths = buildSettings[SEARCH_PATHS]; if (searchPaths && Array.isArray(searchPaths)) { - var matches = searchPaths.filter(function(p) { + var matches = searchPaths.filter(function (p) { return p.indexOf(new_path) > -1; }); - matches.forEach(function(m) { + matches.forEach(function (m) { var idx = searchPaths.indexOf(m); searchPaths.splice(idx, 1); }); } - } -} +}; -pbxProject.prototype.addToLibrarySearchPaths = function(file) { +pbxProject.prototype.addToLibrarySearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var INHERITED = '"$(inherited)"'; var config; @@ -1251,23 +1222,22 @@ pbxProject.prototype.addToLibrarySearchPaths = function(file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } - if (!buildSettings['LIBRARY_SEARCH_PATHS'] - || buildSettings['LIBRARY_SEARCH_PATHS'] === INHERITED) { - buildSettings['LIBRARY_SEARCH_PATHS'] = [INHERITED]; + if (!buildSettings.LIBRARY_SEARCH_PATHS || + buildSettings.LIBRARY_SEARCH_PATHS === INHERITED) { + buildSettings.LIBRARY_SEARCH_PATHS = [INHERITED]; } if (typeof file === 'string') { - buildSettings['LIBRARY_SEARCH_PATHS'].push(file); + buildSettings.LIBRARY_SEARCH_PATHS.push(file); } else { - buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this)); + buildSettings.LIBRARY_SEARCH_PATHS.push(searchPathForFile(file, this)); } } -} +}; -pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { +pbxProject.prototype.removeFromHeaderSearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var INHERITED = '"$(inherited)"'; var SEARCH_PATHS = 'HEADER_SEARCH_PATHS'; @@ -1279,22 +1249,20 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } if (buildSettings[SEARCH_PATHS]) { - var matches = buildSettings[SEARCH_PATHS].filter(function(p) { + var matches = buildSettings[SEARCH_PATHS].filter(function (p) { return p.indexOf(new_path) > -1; }); - matches.forEach(function(m) { + matches.forEach(function (m) { var idx = buildSettings[SEARCH_PATHS].indexOf(m); buildSettings[SEARCH_PATHS].splice(idx, 1); }); } - } -} -pbxProject.prototype.addToHeaderSearchPaths = function(file) { +}; +pbxProject.prototype.addToHeaderSearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var INHERITED = '"$(inherited)"'; var config; @@ -1304,20 +1272,19 @@ pbxProject.prototype.addToHeaderSearchPaths = function(file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } - if (!buildSettings['HEADER_SEARCH_PATHS']) { - buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED]; + if (!buildSettings.HEADER_SEARCH_PATHS) { + buildSettings.HEADER_SEARCH_PATHS = [INHERITED]; } if (typeof file === 'string') { - buildSettings['HEADER_SEARCH_PATHS'].push(file); + buildSettings.HEADER_SEARCH_PATHS.push(file); } else { - buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this)); + buildSettings.HEADER_SEARCH_PATHS.push(searchPathForFile(file, this)); } } -} +}; pbxProject.prototype.addToOtherLinkerFlags = function (flag) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); @@ -1329,17 +1296,16 @@ pbxProject.prototype.addToOtherLinkerFlags = function (flag) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } - if (!buildSettings[OTHER_LDFLAGS] - || buildSettings[OTHER_LDFLAGS] === INHERITED) { + if (!buildSettings[OTHER_LDFLAGS] || + buildSettings[OTHER_LDFLAGS] === INHERITED) { buildSettings[OTHER_LDFLAGS] = [INHERITED]; } buildSettings[OTHER_LDFLAGS].push(flag); } -} +}; pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); @@ -1350,7 +1316,7 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) { + if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } @@ -1364,7 +1330,7 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { }); } } -} +}; pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); @@ -1376,7 +1342,7 @@ pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { buildSettings[buildSetting] = value; } -} +}; pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); @@ -1390,16 +1356,16 @@ pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { delete buildSettings[buildSetting]; } } -} +}; // a JS getter. hmmm -pbxProject.prototype.__defineGetter__("productName", function() { +pbxProject.prototype.__defineGetter__('productName', function () { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); var config; var productName; for (config in configurations) { - productName = configurations[config].buildSettings['PRODUCT_NAME']; + productName = configurations[config].buildSettings.PRODUCT_NAME; if (productName) { return unquote(productName); @@ -1408,7 +1374,7 @@ pbxProject.prototype.__defineGetter__("productName", function() { }); // check if file is present -pbxProject.prototype.hasFile = function(filePath) { +pbxProject.prototype.hasFile = function (filePath) { var files = nonComments(this.pbxFileReferenceSection()); var file; var id; @@ -1420,9 +1386,9 @@ pbxProject.prototype.hasFile = function(filePath) { } return false; -} +}; -pbxProject.prototype.addTarget = function(name, type, subfolder) { +pbxProject.prototype.addTarget = function (name, type, subfolder) { // Setup uuid and name of new target var targetUuid = this.generateUuid(); @@ -1432,17 +1398,17 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { // Check type against list of allowed target types if (!targetName) { - throw new Error("Target name missing."); + throw new Error('Target name missing.'); } // Check type against list of allowed target types if (!targetType) { - throw new Error("Target type missing."); + throw new Error('Target type missing.'); } // Check type against list of allowed target types if (!producttypeForTargettype(targetType)) { - throw new Error("Target type invalid: " + targetType); + throw new Error('Target type invalid: ' + targetType); } // Build Configuration: Create @@ -1471,49 +1437,47 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { ]; // Build Configuration: Add - var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"'); + var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName + '"'); // Product: Create var productName = targetName; var productType = producttypeForTargettype(targetType); var productFileType = filetypeForProducttype(productType); - var productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}); + var productFile = this.addProductFile(productName, { group: 'Copy Files', target: targetUuid, explicitFileType: productFileType }); var productFileName = productFile.basename; - // Product: Add to build file list this.addToPbxBuildFileSection(productFile); // Target: Create var target = { - uuid: targetUuid, - pbxNativeTarget: { - isa: 'PBXNativeTarget', - name: '"' + targetName + '"', - productName: '"' + targetName + '"', - productReference: productFile.fileRef, - productType: '"' + producttypeForTargettype(targetType) + '"', - buildConfigurationList: buildConfigurations.uuid, - buildPhases: [], - buildRules: [], - dependencies: [] - } + uuid: targetUuid, + pbxNativeTarget: { + isa: 'PBXNativeTarget', + name: '"' + targetName + '"', + productName: '"' + targetName + '"', + productReference: productFile.fileRef, + productType: '"' + producttypeForTargettype(targetType) + '"', + buildConfigurationList: buildConfigurations.uuid, + buildPhases: [], + buildRules: [], + dependencies: [] + } }; // Target: Add to PBXNativeTarget section - this.addToPbxNativeTargetSection(target) + this.addToPbxNativeTargetSection(target); // Product: Embed (only for "extension"-type targets) if (targetType === 'app_extension') { - // Create CopyFiles phase in first target - this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Copy Files', this.getFirstTarget().uuid, targetType) + this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Copy Files', this.getFirstTarget().uuid, targetType); // Add product to CopyFiles phase - this.addToPbxCopyfilesBuildPhase(productFile) + this.addToPbxCopyfilesBuildPhase(productFile); - // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid) + // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid) } else if (targetType === 'watch2_app') { // Create CopyFiles phase in first target this.addBuildPhase( @@ -1551,13 +1515,12 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) { this.addTargetDependency(this.getFirstTarget().uuid, [target.uuid]); } - // Return target on success return target; }; // helper object creation functions -function pbxBuildFileObj(file) { +function pbxBuildFileObj (file) { var obj = Object.create(null); obj.isa = 'PBXBuildFile'; @@ -1568,11 +1531,11 @@ function pbxBuildFileObj(file) { return obj; } -function pbxFileReferenceObj(file) { +function pbxFileReferenceObj (file) { var fileObject = { - isa: "PBXFileReference", - name: "\"" + file.basename + "\"", - path: "\"" + file.path.replace(/\\/g, '/') + "\"", + isa: 'PBXFileReference', + name: '"' + file.basename + '"', + path: '"' + file.path.replace(/\\/g, '/') + '"', sourceTree: file.sourceTree, fileEncoding: file.fileEncoding, lastKnownFileType: file.lastKnownFileType, @@ -1583,7 +1546,7 @@ function pbxFileReferenceObj(file) { return fileObject; } -function pbxGroupChild(file) { +function pbxGroupChild (file) { var obj = Object.create(null); obj.value = file.fileRef; @@ -1592,7 +1555,7 @@ function pbxGroupChild(file) { return obj; } -function pbxBuildPhaseObj(file) { +function pbxBuildPhaseObj (file) { var obj = Object.create(null); obj.value = file.uuid; @@ -1601,9 +1564,8 @@ function pbxBuildPhaseObj(file) { return obj; } -function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) { - - // Add additional properties for 'CopyFiles' build phase +function pbxCopyFilesBuildPhaseObj (obj, folderType, subfolderPath, phaseName) { + // Add additional properties for 'CopyFiles' build phase var DESTINATION_BY_TARGETTYPE = { application: 'wrapper', app_extension: 'plugins', @@ -1618,7 +1580,7 @@ function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) { watch2_app: 'products_directory', watch_extension: 'plugins', watch2_extension: 'plugins' - } + }; var SUBFOLDERSPEC_BY_DESTINATION = { absolute_path: 0, executables: 6, @@ -1631,7 +1593,7 @@ function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) { shared_support: 12, wrapper: 1, xpc_services: 0 - } + }; obj.name = '"' + phaseName + '"'; obj.dstPath = subfolderPath || '""'; @@ -1640,7 +1602,7 @@ function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) { return obj; } -function pbxShellScriptBuildPhaseObj(obj, options, phaseName) { +function pbxShellScriptBuildPhaseObj (obj, options, phaseName) { obj.name = '"' + phaseName + '"'; obj.inputPaths = options.inputPaths || []; obj.outputPaths = options.outputPaths || []; @@ -1650,45 +1612,44 @@ function pbxShellScriptBuildPhaseObj(obj, options, phaseName) { return obj; } -function pbxBuildFileComment(file) { +function pbxBuildFileComment (file) { return longComment(file); } -function pbxFileReferenceComment(file) { +function pbxFileReferenceComment (file) { return file.basename || path.basename(file.path); } -function pbxNativeTargetComment(target) { +function pbxNativeTargetComment (target) { return target.name; } -function longComment(file) { - return f("%s in %s", file.basename, file.group); +function longComment (file) { + return f('%s in %s', file.basename, file.group); } // respect path -function correctForPluginsPath(file, project) { +function correctForPluginsPath (file, project) { return correctForPath(file, project, 'Plugins'); } -function correctForResourcesPath(file, project) { +function correctForResourcesPath (file, project) { return correctForPath(file, project, 'Resources'); } -function correctForFrameworksPath(file, project) { +function correctForFrameworksPath (file, project) { return correctForPath(file, project, 'Frameworks'); } -function correctForPath(file, project, group) { +function correctForPath (file, project, group) { var r_group_dir = new RegExp('^' + group + '[\\\\/]'); - if (project.pbxGroupByName(group).path) - file.path = file.path.replace(r_group_dir, ''); + if (project.pbxGroupByName(group).path) { file.path = file.path.replace(r_group_dir, ''); } return file; } -function searchPathForFile(file, proj) { +function searchPathForFile (file, proj) { var plugins = proj.pbxGroupByName('Plugins'); var pluginsPath = plugins ? plugins.path : null; var fileDir = path.dirname(file.path); @@ -1708,7 +1669,7 @@ function searchPathForFile(file, proj) { } } -function nonComments(obj) { +function nonComments (obj) { var keys = Object.keys(obj); var newObj = {}; var i = 0; @@ -1722,65 +1683,60 @@ function nonComments(obj) { return newObj; } -function unquote(str) { - if (str) return str.replace(/^"(.*)"$/, "$1"); +function unquote (str) { + if (str) return str.replace(/^"(.*)"$/, '$1'); } - function buildPhaseNameForIsa (isa) { - BUILDPHASENAME_BY_ISA = { PBXCopyFilesBuildPhase: 'Copy Files', PBXResourcesBuildPhase: 'Resources', PBXSourcesBuildPhase: 'Sources', PBXFrameworksBuildPhase: 'Frameworks' - } + }; - return BUILDPHASENAME_BY_ISA[isa] + return BUILDPHASENAME_BY_ISA[isa]; } function producttypeForTargettype (targetType) { - PRODUCTTYPE_BY_TARGETTYPE = { - application: 'com.apple.product-type.application', - app_extension: 'com.apple.product-type.app-extension', - bundle: 'com.apple.product-type.bundle', - command_line_tool: 'com.apple.product-type.tool', - dynamic_library: 'com.apple.product-type.library.dynamic', - framework: 'com.apple.product-type.framework', - static_library: 'com.apple.product-type.library.static', - unit_test_bundle: 'com.apple.product-type.bundle.unit-test', - watch_app: 'com.apple.product-type.application.watchapp', - watch2_app: 'com.apple.product-type.application.watchapp2', - watch_extension: 'com.apple.product-type.watchkit-extension', - watch2_extension: 'com.apple.product-type.watchkit2-extension' - }; + application: 'com.apple.product-type.application', + app_extension: 'com.apple.product-type.app-extension', + bundle: 'com.apple.product-type.bundle', + command_line_tool: 'com.apple.product-type.tool', + dynamic_library: 'com.apple.product-type.library.dynamic', + framework: 'com.apple.product-type.framework', + static_library: 'com.apple.product-type.library.static', + unit_test_bundle: 'com.apple.product-type.bundle.unit-test', + watch_app: 'com.apple.product-type.application.watchapp', + watch2_app: 'com.apple.product-type.application.watchapp2', + watch_extension: 'com.apple.product-type.watchkit-extension', + watch2_extension: 'com.apple.product-type.watchkit2-extension' + }; - return PRODUCTTYPE_BY_TARGETTYPE[targetType] + return PRODUCTTYPE_BY_TARGETTYPE[targetType]; } function filetypeForProducttype (productType) { - FILETYPE_BY_PRODUCTTYPE = { - 'com.apple.product-type.application': '"wrapper.application"', - 'com.apple.product-type.app-extension': '"wrapper.app-extension"', - 'com.apple.product-type.bundle': '"wrapper.plug-in"', - 'com.apple.product-type.tool': '"compiled.mach-o.dylib"', - 'com.apple.product-type.library.dynamic': '"compiled.mach-o.dylib"', - 'com.apple.product-type.framework': '"wrapper.framework"', - 'com.apple.product-type.library.static': '"archive.ar"', - 'com.apple.product-type.bundle.unit-test': '"wrapper.cfbundle"', - 'com.apple.product-type.application.watchapp': '"wrapper.application"', - 'com.apple.product-type.application.watchapp2': '"wrapper.application"', - 'com.apple.product-type.watchkit-extension': '"wrapper.app-extension"', - 'com.apple.product-type.watchkit2-extension': '"wrapper.app-extension"' - }; + 'com.apple.product-type.application': '"wrapper.application"', + 'com.apple.product-type.app-extension': '"wrapper.app-extension"', + 'com.apple.product-type.bundle': '"wrapper.plug-in"', + 'com.apple.product-type.tool': '"compiled.mach-o.dylib"', + 'com.apple.product-type.library.dynamic': '"compiled.mach-o.dylib"', + 'com.apple.product-type.framework': '"wrapper.framework"', + 'com.apple.product-type.library.static': '"archive.ar"', + 'com.apple.product-type.bundle.unit-test': '"wrapper.cfbundle"', + 'com.apple.product-type.application.watchapp': '"wrapper.application"', + 'com.apple.product-type.application.watchapp2': '"wrapper.application"', + 'com.apple.product-type.watchkit-extension': '"wrapper.app-extension"', + 'com.apple.product-type.watchkit2-extension': '"wrapper.app-extension"' + }; - return FILETYPE_BY_PRODUCTTYPE[productType] + return FILETYPE_BY_PRODUCTTYPE[productType]; } -pbxProject.prototype.getFirstProject = function() { - +pbxProject.prototype.getFirstProject = function () { // Get pbxProject container var pbxProjectContainer = this.pbxProjectSection(); @@ -1790,15 +1746,15 @@ pbxProject.prototype.getFirstProject = function() { // Get first pbxProject var firstProject = pbxProjectContainer[firstProjectUuid]; - return { + return { uuid: firstProjectUuid, firstProject: firstProject - } -} + }; +}; -pbxProject.prototype.getFirstTarget = function() { +pbxProject.prototype.getFirstTarget = function () { // Get first target's UUID - var firstTargetUuid = this.getFirstProject()['firstProject']['targets'][0].value; + var firstTargetUuid = this.getFirstProject().firstProject.targets[0].value; // Get first pbxNativeTarget var firstTarget = this.pbxNativeTargetSection()[firstTargetUuid]; @@ -1806,17 +1762,17 @@ pbxProject.prototype.getFirstTarget = function() { return { uuid: firstTargetUuid, firstTarget: firstTarget - } -} + }; +}; -pbxProject.prototype.getTarget = function(productType) { +pbxProject.prototype.getTarget = function (productType) { // Find target by product type - var targets = this.getFirstProject()['firstProject']['targets']; + var targets = this.getFirstProject().firstProject.targets; var nativeTargets = this.pbxNativeTargetSection(); for (var i = 0; i < targets.length; i++) { var target = targets[i]; var targetUuid = target.value; - if (nativeTargets[targetUuid]['productType'] === '"' + productType + '"') { + if (nativeTargets[targetUuid].productType === '"' + productType + '"') { // Get pbxNativeTarget var nativeTarget = this.pbxNativeTargetSection()[targetUuid]; return { @@ -1827,46 +1783,42 @@ pbxProject.prototype.getTarget = function(productType) { } return null; -} +}; -/*** NEW ***/ +/** * NEW ***/ pbxProject.prototype.addToPbxGroupType = function (file, groupKey, groupType) { var group = this.getPBXGroupByKeyAndType(groupKey, groupType); if (group && group.children !== undefined) { if (typeof file === 'string') { - //Group Key + // Group Key var childGroup = { - value:file, + value: file }; if (this.getPBXGroupByKey(file)) { childGroup.comment = this.getPBXGroupByKey(file).name; - } - else if (this.getPBXVariantGroupByKey(file)) { + } else if (this.getPBXVariantGroupByKey(file)) { childGroup.comment = this.getPBXVariantGroupByKey(file).name; } group.children.push(childGroup); - } - else { - //File Object + } else { + // File Object group.children.push(pbxGroupChild(file)); } } -} +}; pbxProject.prototype.addToPbxVariantGroup = function (file, groupKey) { this.addToPbxGroupType(file, groupKey, 'PBXVariantGroup'); -} +}; pbxProject.prototype.addToPbxGroup = function (file, groupKey) { this.addToPbxGroupType(file, groupKey, 'PBXGroup'); -} - - +}; -pbxProject.prototype.pbxCreateGroupWithType = function(name, pathName, groupType) { - //Create object +pbxProject.prototype.pbxCreateGroupWithType = function (name, pathName, groupType) { + // Create object var model = { isa: '"' + groupType + '"', children: [], @@ -1876,10 +1828,10 @@ pbxProject.prototype.pbxCreateGroupWithType = function(name, pathName, groupType if (pathName) model.path = pathName; var key = this.generateUuid(); - //Create comment + // Create comment var commendId = key + '_comment'; - //add obj and commentObj to groups; + // add obj and commentObj to groups; var groups = this.hash.project.objects[groupType]; if (!groups) { groups = this.hash.project.objects[groupType] = new Object(); @@ -1888,58 +1840,52 @@ pbxProject.prototype.pbxCreateGroupWithType = function(name, pathName, groupType groups[key] = model; return key; -} +}; -pbxProject.prototype.pbxCreateVariantGroup = function(name) { - return this.pbxCreateGroupWithType(name, undefined, 'PBXVariantGroup') -} +pbxProject.prototype.pbxCreateVariantGroup = function (name) { + return this.pbxCreateGroupWithType(name, undefined, 'PBXVariantGroup'); +}; -pbxProject.prototype.pbxCreateGroup = function(name, pathName) { +pbxProject.prototype.pbxCreateGroup = function (name, pathName) { return this.pbxCreateGroupWithType(name, pathName, 'PBXGroup'); -} - - +}; pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, groupType) { var group = this.getPBXGroupByKeyAndType(groupKey, groupType); if (group) { var groupChildren = group.children; var i; - for(i in groupChildren) { - if(pbxGroupChild(file).value == groupChildren[i].value && + for (i in groupChildren) { + if (pbxGroupChild(file).value == groupChildren[i].value && pbxGroupChild(file).comment == groupChildren[i].comment) { groupChildren.splice(i, 1); break; } } } -} +}; pbxProject.prototype.removeFromPbxGroup = function (file, groupKey) { this.removeFromPbxGroupAndType(file, groupKey, 'PBXGroup'); -} +}; pbxProject.prototype.removeFromPbxVariantGroup = function (file, groupKey) { this.removeFromPbxGroupAndType(file, groupKey, 'PBXVariantGroup'); -} - - +}; -pbxProject.prototype.getPBXGroupByKeyAndType = function(key, groupType) { +pbxProject.prototype.getPBXGroupByKeyAndType = function (key, groupType) { return this.hash.project.objects[groupType][key]; }; -pbxProject.prototype.getPBXGroupByKey = function(key) { - return this.hash.project.objects['PBXGroup'][key]; +pbxProject.prototype.getPBXGroupByKey = function (key) { + return this.hash.project.objects.PBXGroup[key]; }; -pbxProject.prototype.getPBXVariantGroupByKey = function(key) { - return this.hash.project.objects['PBXVariantGroup'][key]; +pbxProject.prototype.getPBXVariantGroupByKey = function (key) { + return this.hash.project.objects.PBXVariantGroup[key]; }; - - -pbxProject.prototype.findPBXGroupKeyAndType = function(criteria, groupType) { +pbxProject.prototype.findPBXGroupKeyAndType = function (criteria, groupType) { var groups = this.hash.project.objects[groupType]; var target; @@ -1951,90 +1897,86 @@ pbxProject.prototype.findPBXGroupKeyAndType = function(criteria, groupType) { if (criteria && criteria.path && criteria.name) { if (criteria.path === group.path && criteria.name === group.name) { target = key; - break + break; } - } - else if (criteria && criteria.path) { + } else if (criteria && criteria.path) { if (criteria.path === group.path) { target = key; - break + break; } - } - else if (criteria && criteria.name) { + } else if (criteria && criteria.name) { if (criteria.name === group.name) { target = key; - break + break; } } } return target; -} +}; -pbxProject.prototype.findPBXGroupKey = function(criteria) { +pbxProject.prototype.findPBXGroupKey = function (criteria) { return this.findPBXGroupKeyAndType(criteria, 'PBXGroup'); -} +}; -pbxProject.prototype.findPBXVariantGroupKey = function(criteria) { +pbxProject.prototype.findPBXVariantGroupKey = function (criteria) { return this.findPBXGroupKeyAndType(criteria, 'PBXVariantGroup'); -} +}; -pbxProject.prototype.addLocalizationVariantGroup = function(name) { +pbxProject.prototype.addLocalizationVariantGroup = function (name) { var groupKey = this.pbxCreateVariantGroup(name); - var resourceGroupKey = this.findPBXGroupKey({name: 'Resources'}); + var resourceGroupKey = this.findPBXGroupKey({ name: 'Resources' }); this.addToPbxGroup(groupKey, resourceGroupKey); var localizationVariantGroup = { uuid: this.generateUuid(), fileRef: groupKey, basename: name - } - this.addToPbxBuildFileSection(localizationVariantGroup); // PBXBuildFile - this.addToPbxResourcesBuildPhase(localizationVariantGroup); //PBXResourcesBuildPhase + }; + this.addToPbxBuildFileSection(localizationVariantGroup); // PBXBuildFile + this.addToPbxResourcesBuildPhase(localizationVariantGroup); // PBXResourcesBuildPhase return localizationVariantGroup; }; pbxProject.prototype.addKnownRegion = function (name) { - if (!this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']) { - this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = []; - } - if (!this.hasKnownRegion(name)) { - this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'].push(name); - } -} + if (!this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions) { + this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions = []; + } + if (!this.hasKnownRegion(name)) { + this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions.push(name); + } +}; pbxProject.prototype.removeKnownRegion = function (name) { - var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']; - if (regions) { - for (var i = 0; i < regions.length; i++) { - if (regions[i] === name) { - regions.splice(i, 1); - break; - } - } - this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = regions; - } -} + var regions = this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions; + if (regions) { + for (var i = 0; i < regions.length; i++) { + if (regions[i] === name) { + regions.splice(i, 1); + break; + } + } + this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions = regions; + } +}; pbxProject.prototype.hasKnownRegion = function (name) { - var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']; - if (regions) { - for (var i in regions) { - if (regions[i] === name) { - return true; - } - } - } - return false; -} + var regions = this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions; + if (regions) { + for (var i in regions) { + if (regions[i] === name) { + return true; + } + } + } + return false; +}; -pbxProject.prototype.getPBXObject = function(name) { +pbxProject.prototype.getPBXObject = function (name) { return this.hash.project.objects[name]; -} - - +}; pbxProject.prototype.addFile = function (path, group, opt) { var file = new pbxFile(path, opt); @@ -2044,42 +1986,38 @@ pbxProject.prototype.addFile = function (path, group, opt) { file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxFileReferenceSection(file); // PBXFileReference if (this.getPBXGroupByKey(group)) { - this.addToPbxGroup(file, group); // PBXGroup - } - else if (this.getPBXVariantGroupByKey(group)) { - this.addToPbxVariantGroup(file, group); // PBXVariantGroup + this.addToPbxGroup(file, group); // PBXGroup + } else if (this.getPBXVariantGroupByKey(group)) { + this.addToPbxVariantGroup(file, group); // PBXVariantGroup } return file; -} +}; pbxProject.prototype.removeFile = function (path, group, opt) { var file = new pbxFile(path, opt); - this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPbxFileReferenceSection(file); // PBXFileReference if (this.getPBXGroupByKey(group)) { - this.removeFromPbxGroup(file, group); // PBXGroup - } - else if (this.getPBXVariantGroupByKey(group)) { - this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup + this.removeFromPbxGroup(file, group); // PBXGroup + } else if (this.getPBXVariantGroupByKey(group)) { + this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup } return file; -} - - +}; -pbxProject.prototype.getBuildProperty = function(prop, build) { +pbxProject.prototype.getBuildProperty = function (prop, build) { var target; var configs = this.pbxXCBuildConfigurationSection(); for (var configName in configs) { if (!COMMENT_KEY.test(configName)) { var config = configs[configName]; - if ( (build && config.name === build) || (build === undefined) ) { + if ((build && config.name === build) || (build === undefined)) { if (config.buildSettings[prop] !== undefined) { target = config.buildSettings[prop]; } @@ -2087,23 +2025,23 @@ pbxProject.prototype.getBuildProperty = function(prop, build) { } } return target; -} +}; -pbxProject.prototype.getBuildConfigByName = function(name) { +pbxProject.prototype.getBuildConfigByName = function (name) { var target = {}; var configs = this.pbxXCBuildConfigurationSection(); for (var configName in configs) { if (!COMMENT_KEY.test(configName)) { var config = configs[configName]; - if (config.name === name) { + if (config.name === name) { target[configName] = config; } } } return target; -} +}; -pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) { +pbxProject.prototype.addDataModelDocument = function (filePath, group, opt) { if (!group) { group = 'Resources'; } @@ -2157,27 +2095,27 @@ pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) { this.addToXcVersionGroupSection(file); return file; -} +}; -pbxProject.prototype.addTargetAttribute = function(prop, value, target) { - var attributes = this.getFirstProject()['firstProject']['attributes']; - if (attributes['TargetAttributes'] === undefined) { - attributes['TargetAttributes'] = {}; +pbxProject.prototype.addTargetAttribute = function (prop, value, target) { + var attributes = this.getFirstProject().firstProject.attributes; + if (attributes.TargetAttributes === undefined) { + attributes.TargetAttributes = {}; } target = target || this.getFirstTarget(); - if (attributes['TargetAttributes'][target.uuid] === undefined) { - attributes['TargetAttributes'][target.uuid] = {}; + if (attributes.TargetAttributes[target.uuid] === undefined) { + attributes.TargetAttributes[target.uuid] = {}; } - attributes['TargetAttributes'][target.uuid][prop] = value; -} + attributes.TargetAttributes[target.uuid][prop] = value; +}; -pbxProject.prototype.removeTargetAttribute = function(prop, target) { - var attributes = this.getFirstProject()['firstProject']['attributes']; +pbxProject.prototype.removeTargetAttribute = function (prop, target) { + var attributes = this.getFirstProject().firstProject.attributes; target = target || this.getFirstTarget(); - if (attributes['TargetAttributes'] && - attributes['TargetAttributes'][target.uuid]) { - delete attributes['TargetAttributes'][target.uuid][prop]; + if (attributes.TargetAttributes && + attributes.TargetAttributes[target.uuid]) { + delete attributes.TargetAttributes[target.uuid][prop]; } -} +}; module.exports = pbxProject; diff --git a/lib/pbxWriter.js b/lib/pbxWriter.js index 4ccfc51..80782de 100644 --- a/lib/pbxWriter.js +++ b/lib/pbxWriter.js @@ -25,43 +25,37 @@ var QUOTED = /^"(.*)"$/; var EventEmitter = require('events').EventEmitter; // indentation -function i(x) { - if (x <=0) - return ''; - else - return INDENT + i(x-1); +function i (x) { + if (x <= 0) { return ''; } else { return INDENT + i(x - 1); } } -function comment(key, parent) { +function comment (key, parent) { var text = parent[key + '_comment']; - if (text) - return text; - else - return null; + if (text) { return text; } else { return null; } } // copied from underscore -function isObject(obj) { - return obj === Object(obj) +function isObject (obj) { + return obj === Object(obj); } -function isArray(obj) { - return Array.isArray(obj) +function isArray (obj) { + return Array.isArray(obj); } -function pbxWriter(contents, options) { +function pbxWriter (contents, options) { if (!options) { - options = {} + options = {}; } if (options.omitEmptyValues === undefined) { - options.omitEmptyValues = false + options.omitEmptyValues = false; } this.contents = contents; this.sync = false; this.indentLevel = 0; - this.omitEmptyValues = options.omitEmptyValues + this.omitEmptyValues = options.omitEmptyValues; } util.inherits(pbxWriter, EventEmitter); @@ -70,37 +64,37 @@ pbxWriter.prototype.write = function (str) { var fmt = f.apply(null, arguments); if (this.sync) { - this.buffer += f("%s%s", i(this.indentLevel), fmt); + this.buffer += f('%s%s', i(this.indentLevel), fmt); } else { // do stream write } -} +}; pbxWriter.prototype.writeFlush = function (str) { var oldIndent = this.indentLevel; this.indentLevel = 0; - this.write.apply(this, arguments) + this.write.apply(this, arguments); this.indentLevel = oldIndent; -} +}; pbxWriter.prototype.writeSync = function () { this.sync = true; - this.buffer = ""; + this.buffer = ''; this.writeHeadComment(); this.writeProject(); return this.buffer; -} +}; pbxWriter.prototype.writeHeadComment = function () { if (this.contents.headComment) { - this.write("// %s\n", this.contents.headComment) + this.write('// %s\n', this.contents.headComment); } -} +}; pbxWriter.prototype.writeProject = function () { var proj = this.contents.project; @@ -108,7 +102,7 @@ pbxWriter.prototype.writeProject = function () { var cmt; var obj; - this.write("{\n") + this.write('{\n'); if (proj) { this.indentLevel++; @@ -121,33 +115,33 @@ pbxWriter.prototype.writeProject = function () { obj = proj[key]; if (isArray(obj)) { - this.writeArray(obj, key) + this.writeArray(obj, key); } else if (isObject(obj)) { - this.write("%s = {\n", key); + this.write('%s = {\n', key); this.indentLevel++; if (key === 'objects') { - this.writeObjectsSections(obj) + this.writeObjectsSections(obj); } else { - this.writeObject(obj) + this.writeObject(obj); } this.indentLevel--; - this.write("};\n"); + this.write('};\n'); } else if (this.omitEmptyValues && (obj === undefined || obj === null)) { continue; } else if (cmt) { - this.write("%s = %s /* %s */;\n", key, obj, cmt) + this.write('%s = %s /* %s */;\n', key, obj, cmt); } else { - this.write("%s = %s;\n", key, obj) + this.write('%s = %s;\n', key, obj); } } this.indentLevel--; } - this.write("}\n") -} + this.write('}\n'); +}; pbxWriter.prototype.writeObject = function (object) { var key; @@ -161,33 +155,33 @@ pbxWriter.prototype.writeObject = function (object) { obj = object[key]; if (isArray(obj)) { - this.writeArray(obj, key) + this.writeArray(obj, key); } else if (isObject(obj)) { - this.write("%s = {\n", key); + this.write('%s = {\n', key); this.indentLevel++; - this.writeObject(obj) + this.writeObject(obj); this.indentLevel--; - this.write("};\n"); + this.write('};\n'); } else { if (this.omitEmptyValues && (obj === undefined || obj === null)) { continue; } else if (cmt) { - this.write("%s = %s /* %s */;\n", key, obj, cmt) + this.write('%s = %s /* %s */;\n', key, obj, cmt); } else { - this.write("%s = %s;\n", key, obj) + this.write('%s = %s;\n', key, obj); } } } -} +}; pbxWriter.prototype.writeObjectsSections = function (objects) { var key; var obj; for (key in objects) { - this.writeFlush("\n") + this.writeFlush('\n'); obj = objects[key]; @@ -199,17 +193,17 @@ pbxWriter.prototype.writeObjectsSections = function (objects) { this.writeSectionComment(key, false); } } -} +}; pbxWriter.prototype.writeArray = function (arr, name) { var i; var entry; - this.write("%s = (\n", name); + this.write('%s = (\n', name); this.indentLevel++; - for (i=0; i < arr.length; i++) { - entry = arr[i] + for (i = 0; i < arr.length; i++) { + entry = arr[i]; if (entry.value && entry.comment) { this.write('%s /* %s */,\n', entry.value, entry.comment); @@ -227,16 +221,16 @@ pbxWriter.prototype.writeArray = function (arr, name) { } this.indentLevel--; - this.write(");\n"); -} + this.write(');\n'); +}; pbxWriter.prototype.writeSectionComment = function (name, begin) { if (begin) { - this.writeFlush("/* Begin %s section */\n", name) + this.writeFlush('/* Begin %s section */\n', name); } else { // end - this.writeFlush("/* End %s section */\n", name) + this.writeFlush('/* End %s section */\n', name); } -} +}; pbxWriter.prototype.writeSection = function (section) { var key; @@ -248,30 +242,30 @@ pbxWriter.prototype.writeSection = function (section) { if (COMMENT_KEY.test(key)) continue; cmt = comment(key, section); - obj = section[key] + obj = section[key]; if (obj.isa == 'PBXBuildFile' || obj.isa == 'PBXFileReference') { this.writeInlineObject(key, cmt, obj); } else { if (cmt) { - this.write("%s /* %s */ = {\n", key, cmt); + this.write('%s /* %s */ = {\n', key, cmt); } else { - this.write("%s = {\n", key); + this.write('%s = {\n', key); } - this.indentLevel++ + this.indentLevel++; - this.writeObject(obj) + this.writeObject(obj); - this.indentLevel-- - this.write("};\n"); + this.indentLevel--; + this.write('};\n'); } } -} +}; pbxWriter.prototype.writeInlineObject = function (n, d, r) { var output = []; - var self = this + var self = this; var inlineObjectHelper = function (name, desc, ref) { var key; @@ -279,9 +273,9 @@ pbxWriter.prototype.writeInlineObject = function (n, d, r) { var obj; if (desc) { - output.push(f("%s /* %s */ = {", name, desc)); + output.push(f('%s /* %s */ = {', name, desc)); } else { - output.push(f("%s = {", name)); + output.push(f('%s = {', name)); } for (key in ref) { @@ -291,30 +285,30 @@ pbxWriter.prototype.writeInlineObject = function (n, d, r) { obj = ref[key]; if (isArray(obj)) { - output.push(f("%s = (", key)); + output.push(f('%s = (', key)); - for (var i=0; i < obj.length; i++) { - output.push(f("%s, ", obj[i])) + for (var i = 0; i < obj.length; i++) { + output.push(f('%s, ', obj[i])); } - output.push("); "); + output.push('); '); } else if (isObject(obj)) { - inlineObjectHelper(key, cmt, obj) + inlineObjectHelper(key, cmt, obj); } else if (self.omitEmptyValues && (obj === undefined || obj === null)) { continue; } else if (cmt) { - output.push(f("%s = %s /* %s */; ", key, obj, cmt)) + output.push(f('%s = %s /* %s */; ', key, obj, cmt)); } else { - output.push(f("%s = %s; ", key, obj)) + output.push(f('%s = %s; ', key, obj)); } } - output.push("}; "); - } + output.push('}; '); + }; inlineObjectHelper(n, d, r); - this.write("%s\n", output.join('').trim()); -} + this.write('%s\n', output.join('').trim()); +}; module.exports = pbxWriter; diff --git a/test/BuildSettings.js b/test/BuildSettings.js index 84bfd49..e5a7998 100644 --- a/test/BuildSettings.js +++ b/test/BuildSettings.js @@ -22,19 +22,19 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; var PRODUCT_NAME = '"KitchenSinktablet"'; exports.addAndRemoveToFromBuildSettings = { - 'add should add the build setting to each configuration section':function(test) { + 'add should add the build setting to each configuration section': function (test) { var buildSetting = 'some/buildSetting'; var value = 'some/buildSetting'; proj.addToBuildSettings(buildSetting, value); @@ -45,7 +45,7 @@ exports.addAndRemoveToFromBuildSettings = { } test.done(); }, - 'remove should remove from the build settings in each configuration section':function(test) { + 'remove should remove from the build settings in each configuration section': function (test) { var buildSetting = 'some/buildSetting'; proj.addToBuildSettings(buildSetting, 'some/buildSetting'); proj.removeFromBuildSettings(buildSetting); @@ -56,4 +56,4 @@ exports.addAndRemoveToFromBuildSettings = { } test.done(); } -} +}; diff --git a/test/FrameworkSearchPaths.js b/test/FrameworkSearchPaths.js index a6b30e0..ff69a54 100644 --- a/test/FrameworkSearchPaths.js +++ b/test/FrameworkSearchPaths.js @@ -23,23 +23,23 @@ var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); var pbxFile = { - path:'some/path/include', - dirname: 'some/path', - customFramework: true -} -function cleanHash() { + path: 'some/path/include', + dirname: 'some/path', + customFramework: true +}; +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; var PRODUCT_NAME = '"KitchenSinktablet"'; exports.addAndRemoveToFromFrameworkSearchPaths = { - 'add should add the path to each configuration section':function(test) { + 'add should add the path to each configuration section': function (test) { proj.addToFrameworkSearchPaths(pbxFile); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { @@ -49,7 +49,7 @@ exports.addAndRemoveToFromFrameworkSearchPaths = { } test.done(); }, - 'remove should remove from the path to each configuration section':function(test) { + 'remove should remove from the path to each configuration section': function (test) { proj.addToFrameworkSearchPaths(pbxFile); proj.removeFromFrameworkSearchPaths(pbxFile); var config = proj.pbxXCBuildConfigurationSection(); @@ -61,4 +61,4 @@ exports.addAndRemoveToFromFrameworkSearchPaths = { } test.done(); } -} +}; diff --git a/test/HeaderSearchPaths.js b/test/HeaderSearchPaths.js index 5b76616..bdf9098 100644 --- a/test/HeaderSearchPaths.js +++ b/test/HeaderSearchPaths.js @@ -22,21 +22,21 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; var PRODUCT_NAME = '"KitchenSinktablet"'; exports.addAndRemoveToFromHeaderSearchPaths = { - 'add should add the path to each configuration section':function(test) { + 'add should add the path to each configuration section': function (test) { proj.addToHeaderSearchPaths({ - path:'some/path/include' + path: 'some/path/include' }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { @@ -46,7 +46,7 @@ exports.addAndRemoveToFromHeaderSearchPaths = { } test.done(); }, - 'add should not mangle string arguments and add to each config section':function(test) { + 'add should not mangle string arguments and add to each config section': function (test) { var includePath = '../../some/path'; proj.addToHeaderSearchPaths(includePath); var config = proj.pbxXCBuildConfigurationSection(); @@ -57,13 +57,13 @@ exports.addAndRemoveToFromHeaderSearchPaths = { } test.done(); }, - 'remove should remove from the path to each configuration section':function(test) { + 'remove should remove from the path to each configuration section': function (test) { var libPath = 'some/path/include'; proj.addToHeaderSearchPaths({ - path:libPath + path: libPath }); proj.removeFromHeaderSearchPaths({ - path:libPath + path: libPath }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { @@ -74,4 +74,4 @@ exports.addAndRemoveToFromHeaderSearchPaths = { } test.done(); } -} +}; diff --git a/test/LibrarySearchPaths.js b/test/LibrarySearchPaths.js index 0fcfbe9..4b8f6f4 100644 --- a/test/LibrarySearchPaths.js +++ b/test/LibrarySearchPaths.js @@ -22,21 +22,21 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; var PRODUCT_NAME = '"KitchenSinktablet"'; exports.addAndRemoveToFromLibrarySearchPaths = { - 'add should add the path to each configuration section':function(test) { + 'add should add the path to each configuration section': function (test) { proj.addToLibrarySearchPaths({ - path:'some/path/poop.a' + path: 'some/path/poop.a' }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { @@ -46,7 +46,7 @@ exports.addAndRemoveToFromLibrarySearchPaths = { } test.done(); }, - 'add should not mangle string arguments and add to each config section':function(test) { + 'add should not mangle string arguments and add to each config section': function (test) { var libPath = '../../some/path'; proj.addToLibrarySearchPaths(libPath); var config = proj.pbxXCBuildConfigurationSection(); @@ -57,13 +57,13 @@ exports.addAndRemoveToFromLibrarySearchPaths = { } test.done(); }, - 'remove should remove from the path to each configuration section':function(test) { + 'remove should remove from the path to each configuration section': function (test) { var libPath = 'some/path/poop.a'; proj.addToLibrarySearchPaths({ - path:libPath + path: libPath }); proj.removeFromLibrarySearchPaths({ - path:libPath + path: libPath }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { @@ -74,4 +74,4 @@ exports.addAndRemoveToFromLibrarySearchPaths = { } test.done(); } -} +}; diff --git a/test/OtherLinkerFlags.js b/test/OtherLinkerFlags.js index 2a4225c..d8e1460 100644 --- a/test/OtherLinkerFlags.js +++ b/test/OtherLinkerFlags.js @@ -22,19 +22,19 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; var PRODUCT_NAME = '"KitchenSinktablet"'; exports.addAndRemoveToFromOtherLinkerFlags = { - 'add should add the flag to each configuration section':function(test) { + 'add should add the flag to each configuration section': function (test) { var flag = 'some/flag'; proj.addToOtherLinkerFlags(flag); var config = proj.pbxXCBuildConfigurationSection(); @@ -45,7 +45,7 @@ exports.addAndRemoveToFromOtherLinkerFlags = { } test.done(); }, - 'remove should remove from the path to each configuration section':function(test) { + 'remove should remove from the path to each configuration section': function (test) { var flag = 'some/flag'; proj.addToOtherLinkerFlags(flag); proj.removeFromOtherLinkerFlags(flag); @@ -58,4 +58,4 @@ exports.addAndRemoveToFromOtherLinkerFlags = { } test.done(); } -} +}; diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index e694344..0ceb61b 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -21,27 +21,27 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addBuildPhase = { 'should return a pbxBuildPhase': function (test) { var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); test.ok(typeof buildPhase === 'object'); - test.done() + test.done(); }, 'should set a uuid on the pbxBuildPhase': function (test) { var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); test.ok(buildPhase.uuid); - test.done() + test.done(); }, 'should add all files to build phase': function (test) { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; @@ -50,7 +50,7 @@ exports.addBuildPhase = { test.ok(file.value); } - test.done() + test.done(); }, 'should add the PBXBuildPhase object correctly': function (test) { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; @@ -98,8 +98,8 @@ exports.addBuildPhase = { test.done(); }, 'should not add files to PBXBuildFile section if already added': function (test) { - var buildFileSection = proj.pbxBuildFileSection(); - var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var buildFileSection = proj.pbxBuildFileSection(); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); var buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); @@ -188,11 +188,11 @@ exports.addBuildPhase = { test.equal(buildPhase.dstSubfolderSpec, 13); test.done(); }, - 'should add a script build phase to echo "hello world!"': function(test) { - var options = {shellPath: '/bin/sh', shellScript: 'echo "hello world!"'}; + 'should add a script build phase to echo "hello world!"': function (test) { + var options = { shellPath: '/bin/sh', shellScript: 'echo "hello world!"' }; var buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; test.equal(buildPhase.shellPath, '/bin/sh'); test.equal(buildPhase.shellScript, '"echo \\"hello world!\\""'); test.done(); - }, -} + } +}; diff --git a/test/addFramework.js b/test/addFramework.js index de28b9e..5ef2350 100644 --- a/test/addFramework.js +++ b/test/addFramework.js @@ -22,16 +22,16 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; -function nonComments(obj) { +function nonComments (obj) { var keys = Object.keys(obj); var newObj = {}; var i = 0; @@ -45,18 +45,18 @@ function nonComments(obj) { return newObj; } -function frameworkSearchPaths(proj) { +function frameworkSearchPaths (proj) { var configs = nonComments(proj.pbxXCBuildConfigurationSection()); var allPaths = []; var ids = Object.keys(configs); var i; var buildSettings; - for (i = 0; i< ids.length; i++) { + for (i = 0; i < ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; - if (buildSettings['FRAMEWORK_SEARCH_PATHS']) { - allPaths.push(buildSettings['FRAMEWORK_SEARCH_PATHS']); + if (buildSettings.FRAMEWORK_SEARCH_PATHS) { + allPaths.push(buildSettings.FRAMEWORK_SEARCH_PATHS); } } @@ -68,18 +68,18 @@ exports.addFramework = { var newFile = proj.addFramework('libsqlite3.dylib'); test.equal(newFile.constructor, pbxFile); - test.done() + test.done(); }, 'should set a fileRef on the pbxFile': function (test) { var newFile = proj.addFramework('libsqlite3.dylib'); test.ok(newFile.fileRef); - test.done() + test.done(); }, 'should populate the PBXFileReference section with 2 fields': function (test) { var newFile = proj.addFramework('libsqlite3.dylib'); - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + fileRefSection = proj.pbxFileReferenceSection(), + frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -89,8 +89,8 @@ exports.addFramework = { }, 'should populate the PBXFileReference comment correctly': function (test) { var newFile = proj.addFramework('libsqlite3.dylib'); - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + fileRefSection = proj.pbxFileReferenceSection(), + commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'libsqlite3.dylib'); test.done(); @@ -147,7 +147,7 @@ exports.addFramework = { test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); test.equal(buildFileEntry.fileRef_comment, 'libsqlite3.dylib'); - test.deepEqual(buildFileEntry.settings, { ATTRIBUTES: [ 'Weak' ] }); + test.deepEqual(buildFileEntry.settings, { ATTRIBUTES: ['Weak'] }); test.done(); }, @@ -176,7 +176,7 @@ exports.addFramework = { test.done(); }, 'should not add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('Private.framework', {link: false}); + var newFile = proj.addFramework('Private.framework', { link: false }); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); @@ -200,7 +200,7 @@ exports.addFramework = { } }, 'should pbxFile correctly for custom frameworks': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', {customFramework: true}); + var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true }); test.ok(newFile.customFramework); test.ok(!newFile.fileEncoding); @@ -211,10 +211,9 @@ exports.addFramework = { // XXX framework has to be copied over to PROJECT root. That is what XCode does when you drag&drop test.equal(newFile.path, '/path/to/Custom.framework'); - // should add path to framework search path var frameworkPaths = frameworkSearchPaths(proj); - expectedPath = '"\\"/path/to\\""'; + expectedPath = '"\\"/path/to\\""'; for (i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; @@ -224,7 +223,7 @@ exports.addFramework = { test.done(); }, 'should add to the Embed Frameworks PBXCopyFilesBuildPhase': function (test) { - var newFile = proj.addFramework('/path/to/SomeEmbeddableCustom.framework', {customFramework: true, embed: true}); + var newFile = proj.addFramework('/path/to/SomeEmbeddableCustom.framework', { customFramework: true, embed: true }); var frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); var buildPhaseInPbx = proj.pbxEmbedFrameworksBuildPhaseObj(); @@ -234,7 +233,7 @@ exports.addFramework = { test.done(); }, 'should not add to the Embed Frameworks PBXCopyFilesBuildPhase by default': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', {customFramework: true}); + var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true }); var frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 0); @@ -249,8 +248,8 @@ exports.addFramework = { test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); test.equal(buildFileEntry.fileRef_comment, 'SomeSignable.framework'); - test.deepEqual(buildFileEntry.settings, { ATTRIBUTES: [ 'CodeSignOnCopy' ] }); + test.deepEqual(buildFileEntry.settings, { ATTRIBUTES: ['CodeSignOnCopy'] }); test.done(); - }, -} + } +}; diff --git a/test/addHeaderFile.js b/test/addHeaderFile.js index 4b71ba2..b1254bc 100644 --- a/test/addHeaderFile.js +++ b/test/addHeaderFile.js @@ -22,27 +22,27 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addHeaderFile = { 'should return a pbxFile': function (test) { var newFile = proj.addHeaderFile('file.h'); test.equal(newFile.constructor, pbxFile); - test.done() + test.done(); }, 'should set a fileRef on the pbxFile': function (test) { var newFile = proj.addHeaderFile('file.h'); test.ok(newFile.fileRef); - test.done() + test.done(); }, 'should populate the PBXFileReference section with 2 fields': function (test) { var newFile = proj.addHeaderFile('file.h'); @@ -113,4 +113,4 @@ exports.addHeaderFile = { test.done(); } } -} +}; diff --git a/test/addRemovePbxGroup.js b/test/addRemovePbxGroup.js index 9926084..65c278e 100644 --- a/test/addRemovePbxGroup.js +++ b/test/addRemovePbxGroup.js @@ -21,27 +21,27 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addRemovePbxGroup = { 'should return a pbxGroup': function (test) { var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application', 'Application', '""'); test.ok(typeof pbxGroup === 'object'); - test.done() + test.done(); }, 'should set a uuid on the pbxGroup': function (test) { var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application', 'Application', '""'); test.ok(pbxGroup.uuid); - test.done() + test.done(); }, 'should add all files to pbxGroup': function (test) { var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application', 'Application', '""'); @@ -50,11 +50,11 @@ exports.addRemovePbxGroup = { test.ok(file.value); } - test.done() + test.done(); }, 'should add the PBXGroup object correctly': function (test) { var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application', '""'); - pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); + pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); test.equal(pbxGroupInPbx.children, pbxGroup.pbxGroup.children); test.equal(pbxGroupInPbx.isa, 'PBXGroup'); @@ -64,7 +64,7 @@ exports.addRemovePbxGroup = { }, 'should add sourceTree if no other specified': function (test) { var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application'); - pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); + pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); test.equal(pbxGroupInPbx.sourceTree, '""'); test.done(); @@ -132,7 +132,7 @@ exports.addRemovePbxGroup = { test.done(); }, 'should not add any of the files to PBXFileReference section if already added': function (test) { - var fileReference = proj.pbxFileReferenceSection (); + var fileReference = proj.pbxFileReferenceSection(); var initialBuildFileSectionItemsCount = Object.keys(fileReference); var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); @@ -141,7 +141,7 @@ exports.addRemovePbxGroup = { test.done(); }, 'should not add any of the files to PBXFileReference section when they contain special symbols and are already added': function (test) { - var fileReference = proj.pbxFileReferenceSection (); + var fileReference = proj.pbxFileReferenceSection(); var initialBuildFileSectionItemsCount = Object.keys(fileReference); var pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); @@ -150,7 +150,7 @@ exports.addRemovePbxGroup = { test.done(); }, 'should add all files which are not added and not add files already added to PBXFileReference section': function (test) { - var fileReference = proj.pbxFileReferenceSection (); + var fileReference = proj.pbxFileReferenceSection(); for (var key in fileReference) { test.notEqual(fileReference[key].fileRef_comment, 'file.m'); test.notEqual(fileReference[key].fileRef_comment, 'assets.bundle'); @@ -173,6 +173,6 @@ exports.addRemovePbxGroup = { console.log(pbxGroupInPbx); test.ok(!pbxGroupInPbx); - test.done() + test.done(); } -} +}; diff --git a/test/addResourceFile.js b/test/addResourceFile.js index 4bc14d8..6bc4298 100644 --- a/test/addResourceFile.js +++ b/test/addResourceFile.js @@ -22,33 +22,33 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addResourceFile = { 'should return a pbxFile': function (test) { var newFile = proj.addResourceFile('assets.bundle'); test.equal(newFile.constructor, pbxFile); - test.done() + test.done(); }, 'should set a uuid on the pbxFile': function (test) { var newFile = proj.addResourceFile('assets.bundle'); test.ok(newFile.uuid); - test.done() + test.done(); }, 'should set a fileRef on the pbxFile': function (test) { var newFile = proj.addResourceFile('assets.bundle'); test.ok(newFile.fileRef); - test.done() + test.done(); }, 'should populate the PBXBuildFile section with 2 fields': function (test) { var newFile = proj.addResourceFile('assets.bundle'); @@ -163,7 +163,7 @@ exports.addResourceFile = { delete proj.pbxGroupByName('Plugins').path; var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); var fileRefSection = proj.pbxFileReferenceSection(); var fileRefEntry = fileRefSection[newFile.fileRef]; @@ -179,7 +179,7 @@ exports.addResourceFile = { 'should add to the Plugins PBXGroup group': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); var plugins = proj.pbxGroupByName('Plugins'); @@ -189,7 +189,7 @@ exports.addResourceFile = { 'should have the Plugins values for the PBXGroup entry': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); var plugins = proj.pbxGroupByName('Plugins'); var pluginObj = plugins.children[0]; @@ -201,7 +201,7 @@ exports.addResourceFile = { 'should add to the PBXSourcesBuildPhase': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); var sources = proj.pbxResourcesBuildPhaseObj(); @@ -211,7 +211,7 @@ exports.addResourceFile = { 'should have the right values for the Sources entry': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); var sources = proj.pbxResourcesBuildPhaseObj(); var sourceObj = sources.files[12]; @@ -227,7 +227,7 @@ exports.addResourceFile = { plugins.path = '"Test200/Plugins"'; newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); test.equal(newFile.path, 'assets.bundle'); test.done(); @@ -246,7 +246,7 @@ exports.addResourceFile = { test.ok(buildFileSection[newFile.uuid] === undefined); test.done(); - }, + } }, 'duplicate entries': { @@ -258,10 +258,10 @@ exports.addResourceFile = { }, 'should return false (plugin entries)': function (test) { var newFile = proj.addResourceFile('Plugins/assets.bundle', - { plugin: true }); + { plugin: true }); test.ok(!proj.addResourceFile('Plugins/assets.bundle', - { plugin: true })); + { plugin: true })); test.done(); }, 'should not add another entry anywhere': function (test) { @@ -287,4 +287,4 @@ exports.addResourceFile = { delete proj.pbxGroupByName('Resources').path; callback(); } -} +}; diff --git a/test/addSourceFile.js b/test/addSourceFile.js index ee005f8..28f8b6f 100644 --- a/test/addSourceFile.js +++ b/test/addSourceFile.js @@ -22,33 +22,33 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addSourceFile = { 'should return a pbxFile': function (test) { var newFile = proj.addSourceFile('file.m'); test.equal(newFile.constructor, pbxFile); - test.done() + test.done(); }, 'should set a uuid on the pbxFile': function (test) { var newFile = proj.addSourceFile('file.m'); test.ok(newFile.uuid); - test.done() + test.done(); }, 'should set a fileRef on the pbxFile': function (test) { var newFile = proj.addSourceFile('file.m'); test.ok(newFile.fileRef); - test.done() + test.done(); }, 'should populate the PBXBuildFile section with 2 fields': function (test) { var newFile = proj.addSourceFile('file.m'); @@ -164,12 +164,11 @@ exports.addSourceFile = { // duplicate! proj.addSourceFile('Plugins/file.m'); - test.equal(60, bfsLength); // BuildFileSection - test.equal(68, frsLength); // FileReferenceSection + test.equal(60, bfsLength); // BuildFileSection + test.equal(68, frsLength); // FileReferenceSection test.equal(plugins.children.length, 1); // Plugins pbxGroup - test.equal(sources.files.length, 3); // SourcesBuildPhhase + test.equal(sources.files.length, 3); // SourcesBuildPhhase test.done(); } } -} - +}; diff --git a/test/addStaticLibrary.js b/test/addStaticLibrary.js index 5bdebec..1131b7d 100644 --- a/test/addStaticLibrary.js +++ b/test/addStaticLibrary.js @@ -22,11 +22,11 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } -function nonComments(obj) { +function nonComments (obj) { var keys = Object.keys(obj); var newObj = {}; var i = 0; @@ -40,18 +40,18 @@ function nonComments(obj) { return newObj; } -function librarySearchPaths(proj) { +function librarySearchPaths (proj) { var configs = nonComments(proj.pbxXCBuildConfigurationSection()); var allPaths = []; var ids = Object.keys(configs); var i; var buildSettings; - for (i = 0; i< ids.length; i++) { + for (i = 0; i < ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; - if (buildSettings['LIBRARY_SEARCH_PATHS']) { - allPaths.push(buildSettings['LIBRARY_SEARCH_PATHS']); + if (buildSettings.LIBRARY_SEARCH_PATHS) { + allPaths.push(buildSettings.LIBRARY_SEARCH_PATHS); } } @@ -61,25 +61,25 @@ function librarySearchPaths(proj) { exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addStaticLibrary = { 'should return a pbxFile': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); test.equal(newFile.constructor, pbxFile); - test.done() + test.done(); }, 'should set a fileRef on the pbxFile': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); test.ok(newFile.fileRef); - test.done() + test.done(); }, 'should populate the PBXBuildFile section with 2 fields': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + buildFileSection = proj.pbxBuildFileSection(), + bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -89,9 +89,9 @@ exports.addStaticLibrary = { }, 'should populate the PBXBuildFile section with 2 fields as plugin': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a', - { plugin: true }); - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + { plugin: true }); + buildFileSection = proj.pbxBuildFileSection(), + bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -101,16 +101,16 @@ exports.addStaticLibrary = { }, 'should add the PBXBuildFile comment correctly': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + commentKey = newFile.uuid + '_comment', + buildFileSection = proj.pbxBuildFileSection(); test.equal(buildFileSection[commentKey], 'libGoogleAnalytics.a in Frameworks'); test.done(); }, 'should add the PBXBuildFile object correctly': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + buildFileSection = proj.pbxBuildFileSection(), + buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); @@ -120,8 +120,8 @@ exports.addStaticLibrary = { }, 'should populate the PBXFileReference section with 2 fields': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + fileRefSection = proj.pbxFileReferenceSection(), + frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -131,8 +131,8 @@ exports.addStaticLibrary = { }, 'should populate the PBXFileReference comment correctly': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + fileRefSection = proj.pbxFileReferenceSection(), + commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'libGoogleAnalytics.a'); test.done(); @@ -173,11 +173,11 @@ exports.addStaticLibrary = { var i; var buildSettings; - for (i = 0; i< ids.length; i++) { + for (i = 0; i < ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; - if (buildSettings['PRODUCT_NAME'] == '"KitchenSinktablet"') { - test.ok(buildSettings['LIBRARY_SEARCH_PATHS']); + if (buildSettings.PRODUCT_NAME == '"KitchenSinktablet"') { + test.ok(buildSettings.LIBRARY_SEARCH_PATHS); } } @@ -213,7 +213,7 @@ exports.addStaticLibrary = { }, 'should add to the Plugins group, optionally': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a', - { plugin: true }); + { plugin: true }); var plugins = proj.pbxGroupByName('Plugins'); @@ -226,7 +226,7 @@ exports.addStaticLibrary = { plugins.path = '"Test200/Plugins"'; var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', - { plugin: true }); + { plugin: true }); var libraryPaths = librarySearchPaths(proj); var expectedPath = '"\\"$(SRCROOT)/Test200/Plugins\\""'; @@ -236,7 +236,7 @@ exports.addStaticLibrary = { for (i = 0; i < libraryPaths.length; i++) { current = libraryPaths[i]; test.ok(current.indexOf(expectedPath) >= 0, - expectedPath + ' not found in ' + current); + expectedPath + ' not found in ' + current); } test.done(); @@ -246,7 +246,7 @@ exports.addStaticLibrary = { delete plugins.path; var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', - { plugin: true }); + { plugin: true }); var libraryPaths = librarySearchPaths(proj); var expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet/Plugins\\""'; @@ -256,7 +256,7 @@ exports.addStaticLibrary = { for (i = 0; i < libraryPaths.length; i++) { current = libraryPaths[i]; test.ok(current.indexOf(expectedPath) >= 0, - expectedPath + ' not found in ' + current); + expectedPath + ' not found in ' + current); } test.done(); @@ -271,11 +271,11 @@ exports.addStaticLibrary = { }, 'should return false (plugin entries)': function (test) { var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', - { plugin: true }); + { plugin: true }); test.ok(!proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', - { plugin: true })); + { plugin: true })); test.done(); - }, + } } -} +}; diff --git a/test/addTarget.js b/test/addTarget.js index 8207e9d..65d22b6 100644 --- a/test/addTarget.js +++ b/test/addTarget.js @@ -22,7 +22,7 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } @@ -33,24 +33,24 @@ var TARGET_SUBFOLDER_NAME = 'TestExtensionFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addTarget = { 'should throw when target name is missing': function (test) { - test.throws(function() { + test.throws(function () { proj.addTarget(null, TARGET_TYPE); }); test.done(); }, 'should throw when provided blank or empty target name': function (test) { - test.throws(function() { + test.throws(function () { proj.addTarget('', TARGET_TYPE); }, function (error) { return (error instanceof Error) && /Target name missing/i.test(error); }); - test.throws(function() { + test.throws(function () { proj.addTarget(' ', TARGET_TYPE); }, function (error) { return (error instanceof Error) && /Target name missing/i.test(error); @@ -59,7 +59,7 @@ exports.addTarget = { test.done(); }, 'should throw when target type missing': function (test) { - test.throws(function() { + test.throws(function () { proj.addTarget(TARGET_NAME, null); }, function (error) { return (error instanceof Error) && /Target type missing/i.test(error); @@ -68,7 +68,7 @@ exports.addTarget = { test.done(); }, 'should throw when invalid target type': function (test) { - test.throws(function() { + test.throws(function () { proj.addTarget(TARGET_NAME, 'invalid_target_type'); }, function (error) { return (error instanceof Error) && /Target type invalid/i.test(error); @@ -79,7 +79,7 @@ exports.addTarget = { 'should create a new target': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -114,16 +114,16 @@ exports.addTarget = { test.equal(pbxConfig.isa, 'XCBuildConfiguration'); test.ok(pbxConfig.buildSettings); if (index === 0) { - var debugConfig = pbxConfig.buildSettings['GCC_PREPROCESSOR_DEFINITIONS']; + var debugConfig = pbxConfig.buildSettings.GCC_PREPROCESSOR_DEFINITIONS; test.ok(debugConfig); test.equal(debugConfig.length, 2); test.equal(debugConfig[0], '"DEBUG=1"'); test.equal(debugConfig[1], '"$(inherited)"'); } - test.equal(pbxConfig.buildSettings['INFOPLIST_FILE'], '"' + TARGET_SUBFOLDER_NAME + '/' + TARGET_SUBFOLDER_NAME + '-Info.plist"'); - test.equal(pbxConfig.buildSettings['LD_RUNPATH_SEARCH_PATHS'], '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"'); - test.equal(pbxConfig.buildSettings['PRODUCT_NAME'], '"' + TARGET_NAME + '"'); - test.equal(pbxConfig.buildSettings['SKIP_INSTALL'], 'YES'); + test.equal(pbxConfig.buildSettings.INFOPLIST_FILE, '"' + TARGET_SUBFOLDER_NAME + '/' + TARGET_SUBFOLDER_NAME + '-Info.plist"'); + test.equal(pbxConfig.buildSettings.LD_RUNPATH_SEARCH_PATHS, '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"'); + test.equal(pbxConfig.buildSettings.PRODUCT_NAME, '"' + TARGET_NAME + '"'); + test.equal(pbxConfig.buildSettings.SKIP_INSTALL, 'YES'); }); test.done(); @@ -150,7 +150,7 @@ exports.addTarget = { }, 'should create a new target and add source, framework, resource and header files and the corresponding build phases': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - var options = { 'target' : target.uuid }; + var options = { target: target.uuid }; var sourceFile = proj.addSourceFile('Plugins/file.m', options); var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); var resourceFile = proj.addResourceFile('assets.bundle', options); @@ -168,7 +168,7 @@ exports.addTarget = { test.equal(frameworkFile.constructor, pbxFile); test.equal(headerFile.constructor, pbxFile); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -217,9 +217,9 @@ exports.addTarget = { test.ok(target); test.ok(target.uuid); - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; - var targetDependencyUuid = Object.keys(pbxTargetDependencySection).find( (key) => pbxTargetDependencySection[key].target === target.uuid); + var targetDependencyUuid = Object.keys(pbxTargetDependencySection).find((key) => pbxTargetDependencySection[key].target === target.uuid); test.ok(targetDependencyUuid); var firstTarget = proj.getFirstTarget(); @@ -227,7 +227,7 @@ exports.addTarget = { test.ok(firstTarget.firstTarget); test.ok(firstTarget.firstTarget.dependencies); - var firstTargetMatchingDependency = firstTarget.firstTarget.dependencies.find( (elem) => elem.value === targetDependencyUuid); + var firstTargetMatchingDependency = firstTarget.firstTarget.dependencies.find((elem) => elem.value === targetDependencyUuid); test.ok(firstTargetMatchingDependency); test.done(); @@ -388,4 +388,4 @@ exports.addTarget = { test.done(); } -} +}; diff --git a/test/addTargetDependency.js b/test/addTargetDependency.js index 6034869..ad42c8d 100644 --- a/test/addTargetDependency.js +++ b/test/addTargetDependency.js @@ -21,42 +21,42 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addTargetDependency = { 'should return undefined when no target specified': function (test) { var buildPhase = proj.addTargetDependency(); test.ok(typeof buildPhase === 'undefined'); - test.done() + test.done(); }, 'should throw when target not found in nativeTargetsSection': function (test) { - test.throws(function() { + test.throws(function () { proj.addTargetDependency('invalidTarget'); }, function (error) { return (error instanceof Error) && /Invalid target/i.test(error); }); - test.done() + test.done(); }, 'should throw when any dependency target not found in nativeTargetsSection': function (test) { - test.throws(function() { + test.throws(function () { proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['invalidTarget']); }, function (error) { return (error instanceof Error) && /Invalid target/i.test(error); }); - test.done() + test.done(); }, 'should return the pbxTarget': function (test) { var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54']); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.target); test.done(); @@ -66,11 +66,11 @@ exports.addTargetDependency = { test.deepEqual(targetInPbxProj.dependencies, []); var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; - test.deepEqual(targetInPbxProj.dependencies, target.dependencies) - test.done() + test.deepEqual(targetInPbxProj.dependencies, target.dependencies); + test.done(); }, 'should not modify native target dependencies if PBXTargetDependency object does not exist': function (test) { - delete proj.hash.project.objects['PBXTargetDependency']; + delete proj.hash.project.objects.PBXTargetDependency; var numDependenciesBefore = proj.pbxNativeTargetSection()['1D6058900D05DD3D006BFB54'].dependencies.length; proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54']); @@ -81,7 +81,7 @@ exports.addTargetDependency = { test.done(); }, 'should not modify native target dependencies if PBXContainerItemProxy object does not exist': function (test) { - delete proj.hash.project.objects['PBXContainerItemProxy']; + delete proj.hash.project.objects.PBXContainerItemProxy; var numDependenciesBefore = proj.pbxNativeTargetSection()['1D6058900D05DD3D006BFB54'].dependencies.length; proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54']); @@ -92,7 +92,7 @@ exports.addTargetDependency = { test.done(); }, 'should create a PBXTargetDependency for each dependency target': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { @@ -100,10 +100,10 @@ exports.addTargetDependency = { test.ok(pbxTargetDependencySection[dependency]); } - test.done() + test.done(); }, 'should set right comment for each target dependency': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { @@ -111,10 +111,10 @@ exports.addTargetDependency = { test.equal(pbxTargetDependencySection[dependencyCommentKey], 'PBXTargetDependency'); } - test.done() + test.done(); }, 'should set right comment for each dependency target': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { @@ -130,22 +130,22 @@ exports.addTargetDependency = { test.done(); }, 'should create a PBXContainerItemProxy for each PBXTargetDependency': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; - var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var targetProxy = pbxTargetDependencySection[dependency].targetProxy; test.ok(pbxContainerItemProxySection[targetProxy]); } - test.done() + test.done(); }, 'should set right comment for each container item proxy': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB54', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { @@ -164,77 +164,77 @@ exports.addTargetDependency = { test.done(); }, 'should set each PBXContainerItemProxy`s remoteGlobalIDString correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; var remoteGlobalIDStrings = []; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; - var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var targetProxy = pbxTargetDependencySection[dependency].targetProxy; - remoteGlobalIDStrings.push(pbxContainerItemProxySection[targetProxy]['remoteGlobalIDString']); + remoteGlobalIDStrings.push(pbxContainerItemProxySection[targetProxy].remoteGlobalIDString); } test.deepEqual(remoteGlobalIDStrings, ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']); - test.done() + test.done(); }, 'should set each PBXContainerItemProxy`s remoteInfo correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; var remoteInfoArray = []; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; - var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var targetProxy = pbxTargetDependencySection[dependency].targetProxy; - remoteInfoArray.push(pbxContainerItemProxySection[targetProxy]['remoteInfo']); + remoteInfoArray.push(pbxContainerItemProxySection[targetProxy].remoteInfo); } test.deepEqual(remoteInfoArray, ['"KitchenSinktablet"', '"TestApp"']); - test.done() + test.done(); }, 'should set each PBXContainerItemProxy`s containerPortal correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; - var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var targetProxy = pbxTargetDependencySection[dependency].targetProxy; - test.equal(pbxContainerItemProxySection[targetProxy]['containerPortal'], proj.hash.project['rootObject']); + test.equal(pbxContainerItemProxySection[targetProxy].containerPortal, proj.hash.project.rootObject); } - test.done() + test.done(); }, 'should set each PBXContainerItemProxy`s containerPortal_comment correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; - var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var targetProxy = pbxTargetDependencySection[dependency].targetProxy; - test.equal(pbxContainerItemProxySection[targetProxy]['containerPortal_comment'], proj.hash.project['rootObject_comment']); + test.equal(pbxContainerItemProxySection[targetProxy].containerPortal_comment, proj.hash.project.rootObject_comment); } - test.done() + test.done(); }, 'should set each PBXContainerItemProxy`s proxyType correctly': function (test) { - var pbxTargetDependencySection = proj.hash.project.objects['PBXTargetDependency']; - var pbxContainerItemProxySection = proj.hash.project.objects['PBXContainerItemProxy']; + var pbxTargetDependencySection = proj.hash.project.objects.PBXTargetDependency; + var pbxContainerItemProxySection = proj.hash.project.objects.PBXContainerItemProxy; var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target; for (var index = 0; index < target.dependencies.length; index++) { var dependency = target.dependencies[index].value; - var targetProxy = pbxTargetDependencySection[dependency]['targetProxy']; + var targetProxy = pbxTargetDependencySection[dependency].targetProxy; - test.equal(pbxContainerItemProxySection[targetProxy]['proxyType'], 1); + test.equal(pbxContainerItemProxySection[targetProxy].proxyType, 1); } - test.done() + test.done(); } -} +}; diff --git a/test/addToPbxFileReferenceSection.js b/test/addToPbxFileReferenceSection.js index 1be6046..a040b96 100644 --- a/test/addToPbxFileReferenceSection.js +++ b/test/addToPbxFileReferenceSection.js @@ -22,21 +22,21 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var myProj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { myProj.hash = cleanHash(); callback(); -} +}; exports['addToPbxFileReferenceSection function'] = { 'should add file and comment to fileReferenceSection': function (test) { var file = new pbxFile('file.m'); file.fileRef = myProj.generateUuid(); - myProj.addToPbxFileReferenceSection(file) + myProj.addToPbxFileReferenceSection(file); test.equal(myProj.pbxFileReferenceSection()[file.fileRef].isa, 'PBXFileReference'); test.equal(myProj.pbxFileReferenceSection()[file.fileRef].lastKnownFileType, 'sourcecode.c.objc'); @@ -44,13 +44,13 @@ exports['addToPbxFileReferenceSection function'] = { test.equal(myProj.pbxFileReferenceSection()[file.fileRef].path, '"file.m"'); test.equal(myProj.pbxFileReferenceSection()[file.fileRef].sourceTree, '""'); test.equal(myProj.pbxFileReferenceSection()[file.fileRef].fileEncoding, 4); - test.equal(myProj.pbxFileReferenceSection()[file.fileRef + "_comment"], 'file.m'); + test.equal(myProj.pbxFileReferenceSection()[file.fileRef + '_comment'], 'file.m'); test.done(); }, 'should add file with preset explicitFileType to fileReferenceSection correctly': function (test) { - var appexFile = { fileRef: myProj.generateUuid(), isa: 'PBXFileReference', explicitFileType: '"wrapper.app-extension"', path: "WatchKit Extension.appex"}; + var appexFile = { fileRef: myProj.generateUuid(), isa: 'PBXFileReference', explicitFileType: '"wrapper.app-extension"', path: 'WatchKit Extension.appex' }; - myProj.addToPbxFileReferenceSection(appexFile) + myProj.addToPbxFileReferenceSection(appexFile); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].isa, 'PBXFileReference'); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].explicitFileType, '"wrapper.app-extension"'); @@ -58,9 +58,9 @@ exports['addToPbxFileReferenceSection function'] = { test.done(); }, 'should add file with preset includeInIndex to fileReferenceSection correctly': function (test) { - var appexFile = { fileRef: myProj.generateUuid(), isa: 'PBXFileReference', includeInIndex: 0, path: "WatchKit Extension.appex"}; + var appexFile = { fileRef: myProj.generateUuid(), isa: 'PBXFileReference', includeInIndex: 0, path: 'WatchKit Extension.appex' }; - myProj.addToPbxFileReferenceSection(appexFile) + myProj.addToPbxFileReferenceSection(appexFile); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].isa, 'PBXFileReference'); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].includeInIndex, 0); @@ -68,13 +68,13 @@ exports['addToPbxFileReferenceSection function'] = { test.done(); }, 'should add file with preset sourceTree to fileReferenceSection correctly': function (test) { - var appexFile = { fileRef: myProj.generateUuid(), isa: 'PBXFileReference', sourceTree: 'BUILT_PRODUCTS_DIR', path: "WatchKit Extension.appex"}; + var appexFile = { fileRef: myProj.generateUuid(), isa: 'PBXFileReference', sourceTree: 'BUILT_PRODUCTS_DIR', path: 'WatchKit Extension.appex' }; - myProj.addToPbxFileReferenceSection(appexFile) + myProj.addToPbxFileReferenceSection(appexFile); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].isa, 'PBXFileReference'); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].sourceTree, 'BUILT_PRODUCTS_DIR'); test.equal(myProj.pbxFileReferenceSection()[appexFile.fileRef].path, '"WatchKit Extension.appex"'); test.done(); } -} +}; diff --git a/test/addWatch2App.js b/test/addWatch2App.js index 8375ffa..b9017a8 100644 --- a/test/addWatch2App.js +++ b/test/addWatch2App.js @@ -22,7 +22,7 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } @@ -33,13 +33,13 @@ var TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addWatchApp = { 'should create a new watch2 app target with the correct product type': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -59,7 +59,7 @@ exports.addWatchApp = { 'should create a new watch2 app target with the correct product type, without needing a subfolder name': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -78,7 +78,7 @@ exports.addWatchApp = { }, 'should create a new watch2 app target and add source, framework, resource and header files and the corresponding build phases': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - var options = { 'target' : target.uuid }; + var options = { target: target.uuid }; var sourceFile = proj.addSourceFile('Plugins/file.m', options); var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); var resourceFile = proj.addResourceFile('assets.bundle', options); @@ -96,7 +96,7 @@ exports.addWatchApp = { test.equal(frameworkFile.constructor, pbxFile); test.equal(headerFile.constructor, pbxFile); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -114,7 +114,7 @@ exports.addWatchApp = { 'should create a new watch2 app target and add watch build phase': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -143,7 +143,7 @@ exports.addWatchApp = { 'should create a new watch2 app with appropriate target extension': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Watch Content', target.uuid) + var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Watch Content', target.uuid); var buildPhaseFile = buildPhase.files[0]; test.ok(buildPhaseFile.value); @@ -156,10 +156,10 @@ exports.addWatchApp = { test.ok(buildPhaseFileRef.name); test.ok(buildPhaseFileRef.path); - var quotedTargetPath = "\"" + TARGET_NAME + ".app\""; + var quotedTargetPath = '"' + TARGET_NAME + '.app"'; test.equal(buildPhaseFileRef.name, quotedTargetPath); test.equal(buildPhaseFileRef.path, quotedTargetPath); test.done(); } -} +}; diff --git a/test/addWatch2Extension.js b/test/addWatch2Extension.js index 121fd1d..f2fda63 100644 --- a/test/addWatch2Extension.js +++ b/test/addWatch2Extension.js @@ -22,7 +22,7 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } @@ -33,13 +33,13 @@ var TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addWatchExtension = { 'should create a new watch2 extension target with the correct product type': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -57,7 +57,7 @@ exports.addWatchExtension = { }, 'should create a new watch2 extension target and add source, framework, resource and header files and the corresponding build phases': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - var options = { 'target' : target.uuid }; + var options = { target: target.uuid }; var sourceFile = proj.addSourceFile('Plugins/file.m', options); var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); var resourceFile = proj.addResourceFile('assets.bundle', options); @@ -75,7 +75,7 @@ exports.addWatchExtension = { test.equal(frameworkFile.constructor, pbxFile); test.equal(headerFile.constructor, pbxFile); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -93,7 +93,7 @@ exports.addWatchExtension = { 'should not create a new watch2 extension build phase if no watch2 app exists': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -106,7 +106,7 @@ exports.addWatchExtension = { test.ok(target.pbxNativeTarget.buildRules); test.ok(target.pbxNativeTarget.dependencies); - var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid) + var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid); test.ok(!buildPhase); @@ -116,7 +116,7 @@ exports.addWatchExtension = { proj.addTarget('TestWatchApp', 'watch2_app'); var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid) + var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid); test.ok(buildPhase); test.ok(buildPhase.files); @@ -149,12 +149,12 @@ exports.addWatchExtension = { test.equal(nativeTargets[watchApp.uuid].buildPhases.length, 0); test.equal(nativeTargets[watchApp.uuid].dependencies.length, 0); - proj.addTarget(TARGET_NAME, "app_extension"); + proj.addTarget(TARGET_NAME, 'app_extension'); test.equal(nativeTargets[watchApp.uuid].buildPhases.length, 0); test.equal(nativeTargets[watchApp.uuid].dependencies.length, 0); - proj.addTarget(TARGET_NAME, "watch_extension"); + proj.addTarget(TARGET_NAME, 'watch_extension'); test.equal(nativeTargets[watchApp.uuid].buildPhases.length, 0); test.equal(nativeTargets[watchApp.uuid].dependencies.length, 0); @@ -165,7 +165,7 @@ exports.addWatchExtension = { proj.addTarget('TestWatchApp', 'watch2_app'); var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid) + var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid); var buildPhaseFile = buildPhase.files[0]; test.ok(buildPhaseFile.value); @@ -178,10 +178,10 @@ exports.addWatchExtension = { test.ok(buildPhaseFileRef.name); test.ok(buildPhaseFileRef.path); - var quotedTargetPath = "\"" + TARGET_NAME + ".appex\""; + var quotedTargetPath = '"' + TARGET_NAME + '.appex"'; test.equal(buildPhaseFileRef.name, quotedTargetPath); test.equal(buildPhaseFileRef.path, quotedTargetPath); test.done(); } -} +}; diff --git a/test/addWatchApp.js b/test/addWatchApp.js index 746994f..3763b64 100644 --- a/test/addWatchApp.js +++ b/test/addWatchApp.js @@ -22,7 +22,7 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } @@ -33,13 +33,13 @@ var TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addWatchApp = { 'should create a new watch app target with the correct product type': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -59,7 +59,7 @@ exports.addWatchApp = { 'should create a new watch app target with the correct product type, without needing a subfolder name': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -78,7 +78,7 @@ exports.addWatchApp = { }, 'should create a new watch app target and add source, framework, resource and header files and the corresponding build phases': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - var options = { 'target' : target.uuid }; + var options = { target: target.uuid }; var sourceFile = proj.addSourceFile('Plugins/file.m', options); var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); var resourceFile = proj.addResourceFile('assets.bundle', options); @@ -96,7 +96,7 @@ exports.addWatchApp = { test.equal(frameworkFile.constructor, pbxFile); test.equal(headerFile.constructor, pbxFile); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -111,4 +111,4 @@ exports.addWatchApp = { test.done(); } -} +}; diff --git a/test/addWatchExtension.js b/test/addWatchExtension.js index 5be4649..87ea04c 100644 --- a/test/addWatchExtension.js +++ b/test/addWatchExtension.js @@ -22,7 +22,7 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } @@ -33,13 +33,13 @@ var TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles'; exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addWatchExtension = { 'should create a new watch extension target': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -56,7 +56,7 @@ exports.addWatchExtension = { }, 'should create a new watch extension target and add source, framework, resource and header files and the corresponding build phases': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME); - var options = { 'target' : target.uuid }; + var options = { target: target.uuid }; var sourceFile = proj.addSourceFile('Plugins/file.m', options); var sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid); var resourceFile = proj.addResourceFile('assets.bundle', options); @@ -74,7 +74,7 @@ exports.addWatchExtension = { test.equal(frameworkFile.constructor, pbxFile); test.equal(headerFile.constructor, pbxFile); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -92,7 +92,7 @@ exports.addWatchExtension = { 'should not create a new watch extension build phase if no watch app exists': function (test) { var target = proj.addTarget(TARGET_NAME, TARGET_TYPE); - test.ok(typeof target == 'object'); + test.ok(typeof target === 'object'); test.ok(target.uuid); test.ok(target.pbxNativeTarget); test.ok(target.pbxNativeTarget.isa); @@ -105,10 +105,10 @@ exports.addWatchExtension = { test.ok(target.pbxNativeTarget.buildRules); test.ok(target.pbxNativeTarget.dependencies); - var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid) + var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid); test.ok(!buildPhase); test.done(); } -} +}; diff --git a/test/addXCConfigurationList.js b/test/addXCConfigurationList.js index 00bea01..d2e1c8a 100644 --- a/test/addXCConfigurationList.js +++ b/test/addXCConfigurationList.js @@ -26,9 +26,9 @@ var debugConfiguration = { buildSettings: { GCC_PREPROCESSOR_DEFINITIONS: [ '"DEBUG=1"', - '"$(inherited)"', + '"$(inherited)"' ], - INFOPLIST_FILE: "Info.Plist", + INFOPLIST_FILE: 'Info.Plist', LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', PRODUCT_NAME: '"${TARGET_NAME}"', SKIP_INSTALL: 'YES' @@ -39,7 +39,7 @@ var debugConfiguration = { var releaseConfiguration = { isa: 'XCBuildConfiguration', buildSettings: { - INFOPLIST_FILE: "Info.Plist", + INFOPLIST_FILE: 'Info.Plist', LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', PRODUCT_NAME: '"${TARGET_NAME}"', SKIP_INSTALL: 'YES' @@ -47,14 +47,14 @@ var releaseConfiguration = { name: 'Release' }; -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addXCConfigurationList = { 'should return an XCConfigurationList': function (test) { @@ -132,4 +132,4 @@ exports.addXCConfigurationList = { test.done(); } -} +}; diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index c98962c..5660ddd 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -25,40 +25,40 @@ var proj = new pbx('.'); var singleDataModelFilePath = __dirname + '/fixtures/single-data-model.xcdatamodeld'; var multipleDataModelFilePath = __dirname + '/fixtures/multiple-data-model.xcdatamodeld'; -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.dataModelDocument = { 'should return a pbxFile': function (test) { var newFile = proj.addDataModelDocument(singleDataModelFilePath); test.equal(newFile.constructor, pbxFile); - test.done() + test.done(); }, 'should set a uuid on the pbxFile': function (test) { var newFile = proj.addDataModelDocument(singleDataModelFilePath); test.ok(newFile.uuid); - test.done() + test.done(); }, 'should set a fileRef on the pbxFile': function (test) { var newFile = proj.addDataModelDocument(singleDataModelFilePath); test.ok(newFile.fileRef); - test.done() + test.done(); }, 'should set an optional target on the pbxFile': function (test) { var newFile = proj.addDataModelDocument(singleDataModelFilePath, undefined, { target: target }); var target = proj.findTargetKey('TestApp'); test.equal(newFile.target, target); - test.done() + test.done(); }, 'should populate the PBXBuildFile section with 2 fields': function (test) { var newFile = proj.addDataModelDocument(singleDataModelFilePath); @@ -97,8 +97,8 @@ exports.dataModelDocument = { }, 'should add to resources group by default': function (test) { var newFile = proj.addDataModelDocument(singleDataModelFilePath); - groupChildren = proj.pbxGroupByName('Resources').children, - found = false; + groupChildren = proj.pbxGroupByName('Resources').children, + found = false; for (var index in groupChildren) { if (groupChildren[index].comment === 'single-data-model.xcdatamodeld') { @@ -177,4 +177,4 @@ exports.dataModelDocument = { test.done(); } -} +}; diff --git a/test/group.js b/test/group.js index 1088a83..65323cb 100644 --- a/test/group.js +++ b/test/group.js @@ -21,7 +21,7 @@ var pbxFile = require('../lib/pbxFile'); var project; var projectHash; -var findChildInGroup = function(obj, target) { +var findChildInGroup = function (obj, target) { var found = false; for (var i = 0, j = obj.children.length; i < j; i++) { @@ -32,9 +32,9 @@ var findChildInGroup = function(obj, target) { } return found; -} +}; -var findFileByUUID = function(obj, target) { +var findFileByUUID = function (obj, target) { var found = false; for (var k = 0, l = obj.files.length; k < l; k++) { @@ -45,9 +45,9 @@ var findFileByUUID = function(obj, target) { } return found; -} +}; -var findByFileRef = function(obj, target) { +var findByFileRef = function (obj, target) { var found = false; for (var property in obj) { @@ -59,9 +59,9 @@ var findByFileRef = function(obj, target) { } } return found; -} +}; -var findByName = function(obj, target) { +var findByName = function (obj, target) { var found = false; for (var property in obj) { if (!/comment/.test(property)) { @@ -72,39 +72,38 @@ var findByName = function(obj, target) { } } return found; -} +}; -exports.setUp = function(callback) { +exports.setUp = function (callback) { project = new pbx('test/parser/projects/group.pbxproj'); projectHash = project.parseSync(); callback(); -} +}; exports.getGroupByKey = { - 'should return PBXGroup for Classes': function(test) { - var groupKey = project.findPBXGroupKey({name: 'Classes'}); + 'should return PBXGroup for Classes': function (test) { + var groupKey = project.findPBXGroupKey({ name: 'Classes' }); var group = project.getPBXGroupByKey(groupKey); test.ok(group.name === 'Classes'); test.done(); }, - 'should return PBXGroup for Plugins': function(test) { - var groupKey = project.findPBXGroupKey({name: 'Plugins'}); + 'should return PBXGroup for Plugins': function (test) { + var groupKey = project.findPBXGroupKey({ name: 'Plugins' }); var group = project.getPBXGroupByKey(groupKey); test.ok(group.name === 'Plugins'); test.done(); } -} +}; exports.createGroup = { - 'should create a new Test Group': function(test) { + 'should create a new Test Group': function (test) { var found = false; var groups = project.getPBXObject('PBXGroup'); var found = findByName(groups, 'Test'); test.ok(found === false); - - var group = project.findPBXGroupKey({name:'Test'}); + var group = project.findPBXGroupKey({ name: 'Test' }); test.ok(group === undefined); project.pbxCreateGroup('Test', 'Test'); @@ -113,18 +112,18 @@ exports.createGroup = { found = findByName(groups, 'Test'); test.ok(found === true); - group = project.findPBXGroupKey({name:'Test'}); + group = project.findPBXGroupKey({ name: 'Test' }); test.ok(typeof group === 'string'); test.done(); } -} +}; exports.findGroupKey = { - 'should return a valid group key':function(test) { - var keyByName = project.findPBXGroupKey({ name: 'Classes'}); - var keyByPath = project.findPBXGroupKey({ path: 'icons'}); - var keyByPathName = project.findPBXGroupKey({ path: '"HelloCordova/Plugins"', name: 'Plugins'}); - var nonExistingKey = project.findPBXGroupKey({ name: 'Foo'}); + 'should return a valid group key': function (test) { + var keyByName = project.findPBXGroupKey({ name: 'Classes' }); + var keyByPath = project.findPBXGroupKey({ path: 'icons' }); + var keyByPathName = project.findPBXGroupKey({ path: '"HelloCordova/Plugins"', name: 'Plugins' }); + var nonExistingKey = project.findPBXGroupKey({ name: 'Foo' }); test.ok(keyByName === '080E96DDFE201D6D7F000001'); test.ok(keyByPath === '308D052D1370CCF300D202BF'); @@ -133,12 +132,12 @@ exports.findGroupKey = { test.done(); } -} +}; exports.addGroupToGroup = { - 'should create a new test group then add group to Classes group': function(test) { + 'should create a new test group then add group to Classes group': function (test) { var testKey = project.pbxCreateGroup('Test', 'Test'); - var classesKey = project.findPBXGroupKey({name: 'Classes'}); + var classesKey = project.findPBXGroupKey({ name: 'Classes' }); project.addToPbxGroup(testKey, classesKey); var classesGroup = project.getPBXGroupByKey(classesKey); @@ -154,10 +153,10 @@ exports.addGroupToGroup = { test.done(); } -} +}; exports.predefinedPbxGroups = { - setUp: function(callback) { + setUp: function (callback) { project = new pbx('test/parser/projects/empty-groups.pbxproj').parseSync(); this.file = new pbxFile('some-file.m'); @@ -167,14 +166,14 @@ exports.predefinedPbxGroups = { callback(); }, - 'should add a file to "Plugins" group': function(test) { + 'should add a file to "Plugins" group': function (test) { project.addToPluginsPbxGroup(this.file); var foundInGroup = findChildInGroup(project.pbxGroupByName('Plugins'), this.file.fileRef); test.ok(foundInGroup); test.done(); }, - 'should remove a file from "Plugins" group': function(test) { + 'should remove a file from "Plugins" group': function (test) { project.addToPluginsPbxGroup(this.file); project.removeFromPluginsPbxGroup(this.file); @@ -183,7 +182,7 @@ exports.predefinedPbxGroups = { test.done(); }, - 'should add a file to "Resources" group': function(test) { + 'should add a file to "Resources" group': function (test) { project.addToResourcesPbxGroup(this.file); var foundInGroup = findChildInGroup(project.pbxGroupByName('Resources'), this.file.fileRef); @@ -191,7 +190,7 @@ exports.predefinedPbxGroups = { test.done(); }, - 'should remove a file from "Resources" group': function(test) { + 'should remove a file from "Resources" group': function (test) { project.addToResourcesPbxGroup(this.file); project.removeFromResourcesPbxGroup(this.file); @@ -200,7 +199,7 @@ exports.predefinedPbxGroups = { test.done(); }, - 'should add a file to "Frameworks" group': function(test) { + 'should add a file to "Frameworks" group': function (test) { project.addToFrameworksPbxGroup(this.file); var foundInGroup = findChildInGroup(project.pbxGroupByName('Frameworks'), this.file.fileRef); @@ -208,7 +207,7 @@ exports.predefinedPbxGroups = { test.done(); }, - 'should remove a file from "Frameworks" group': function(test) { + 'should remove a file from "Frameworks" group': function (test) { project.addToFrameworksPbxGroup(this.file); project.removeFromFrameworksPbxGroup(this.file); @@ -217,7 +216,7 @@ exports.predefinedPbxGroups = { test.done(); }, - 'should add a file to "Products" group': function(test) { + 'should add a file to "Products" group': function (test) { project.addToProductsPbxGroup(this.file); var foundInGroup = findChildInGroup(project.pbxGroupByName('Products'), this.file.fileRef); @@ -225,7 +224,7 @@ exports.predefinedPbxGroups = { test.done(); }, - 'should remove a file from "Products" group': function(test) { + 'should remove a file from "Products" group': function (test) { project.addToProductsPbxGroup(this.file); project.removeFromProductsPbxGroup(this.file); @@ -236,11 +235,11 @@ exports.predefinedPbxGroups = { }; exports.addSourceFileToGroup = { - 'should create group + add source file' : function(test) { + 'should create group + add source file': function (test) { var testKey = project.pbxCreateGroup('Test', 'Test'); var file = project.addSourceFile('Notifications.m', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(foundInGroup); var foundInBuildFileSection = findByFileRef(project.pbxBuildFileSection(), file.fileRef); @@ -251,14 +250,14 @@ exports.addSourceFileToGroup = { test.done(); } -} +}; exports.removeSourceFileFromGroup = { - 'should create group + add source file then remove source file' : function(test) { + 'should create group + add source file then remove source file': function (test) { var testKey = project.pbxCreateGroup('Test', 'Test'); var file = project.addSourceFile('Notifications.m', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(foundInGroup); var foundInBuildFileSection = findByFileRef(project.pbxBuildFileSection(), file.fileRef); @@ -269,7 +268,7 @@ exports.removeSourceFileFromGroup = { project.removeSourceFile('Notifications.m', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); var foundInBuildFileSection = findByFileRef(project.pbxBuildFileSection(), file.fileRef); @@ -280,85 +279,84 @@ exports.removeSourceFileFromGroup = { test.done(); } -} +}; exports.addHeaderFileToGroup = { - 'should create group + add header file' : function(test) { + 'should create group + add header file': function (test) { var testKey = project.pbxCreateGroup('Test', 'Test'); var file = project.addHeaderFile('Notifications.h', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(foundInGroup); test.done(); } -} +}; exports.removeHeaderFileFromGroup = { - 'should create group + add source file then remove header file' : function(test) { + 'should create group + add source file then remove header file': function (test) { var testKey = project.pbxCreateGroup('Test', 'Test'); var file = project.addHeaderFile('Notifications.h', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(foundInGroup); project.removeHeaderFile('Notifications.h', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); test.done(); } -} +}; exports.addResourceFileToGroup = { - 'should add resource file (PNG) to the splash group' : function(test) { - - var testKey = project.findPBXGroupKey({path:'splash'}); + 'should add resource file (PNG) to the splash group': function (test) { + var testKey = project.findPBXGroupKey({ path: 'splash' }); var file = project.addResourceFile('DefaultTest-667h.png', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(foundInGroup); test.done(); } -} +}; exports.removeResourceFileFromGroup = { - 'should add resource file (PNG) then remove resource file from splash group' : function(test) { - var testKey = project.findPBXGroupKey({path:'splash'}); + 'should add resource file (PNG) then remove resource file from splash group': function (test) { + var testKey = project.findPBXGroupKey({ path: 'splash' }); var file = project.addResourceFile('DefaultTest-667h.png', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(foundInGroup); project.removeResourceFile('DefaultTest-667h.png', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey),file.fileRef ); + var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); test.done(); } -} +}; exports.retrieveBuildPropertyForBuild = { - 'should retrieve valid build property ':function(test) { + 'should retrieve valid build property ': function (test) { var releaseTargetedDeviceFamily = project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Release'); var debugTargetedDeviceFamily = project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Debug'); var nonExistingProperty = project.getBuildProperty('FOO', 'Debug'); var nonExistingBuild = project.getBuildProperty('TARGETED_DEVICE_FAMILY', 'Foo'); test.equal(releaseTargetedDeviceFamily, '"1,2"'); - test.equal(debugTargetedDeviceFamily,'"1"'); + test.equal(debugTargetedDeviceFamily, '"1"'); test.equal(nonExistingProperty, undefined); test.equal(nonExistingBuild, undefined); test.done(); } -} +}; exports.retrieveBuildConfigByName = { - 'should retrieve valid build config':function(test) { + 'should retrieve valid build config': function (test) { var releaseBuildConfig = project.getBuildConfigByName('Release'); for (var property in releaseBuildConfig) { var value = releaseBuildConfig[property]; @@ -376,7 +374,7 @@ exports.retrieveBuildConfigByName = { test.done(); } -} +}; /* This proves the issue in 0.6.7 exports.validatePropReplaceException = { @@ -394,22 +392,22 @@ exports.validatePropReplaceException = { */ exports.validatePropReplaceFix = { - 'should create build configuration for VALID_ARCHS when none existed' : function(test) { + 'should create build configuration for VALID_ARCHS when none existed': function (test) { project.updateBuildProperty('VALID_ARCHS', '"armv7 armv7s"', 'Debug'); test.done(); } -} +}; exports.validateHasFile = { - 'should return true for has file MainViewController.m': function(test) { + 'should return true for has file MainViewController.m': function (test) { var result = project.hasFile('MainViewController.m'); - test.ok(result.path == "MainViewController.m"); + test.ok(result.path == 'MainViewController.m'); test.done(); } -} +}; exports.testWritingPBXProject = { - 'should successfully write to PBXProject TargetAttributes': function(test) { + 'should successfully write to PBXProject TargetAttributes': function (test) { var pbxProjectObj = project.getPBXObject('PBXProject'); var pbxProject; for (var property in pbxProjectObj) { @@ -420,7 +418,7 @@ exports.testWritingPBXProject = { var target; var projectTargets = pbxProject.targets; - for (var i = 0, j = pbxProject.targets.length; i < j; i++ ) { + for (var i = 0, j = pbxProject.targets.length; i < j; i++) { target = pbxProject.targets[i].value; } @@ -428,13 +426,13 @@ exports.testWritingPBXProject = { pbxProject.attributes.TargetAttributes[target] = { DevelopmentTeam: 'N6X4RJZZ5D', SystemCapabilities: { - "com.apple.BackgroundModes": { - enabled : 0 + 'com.apple.BackgroundModes': { + enabled: 0 }, - "com.apple.DataProtection" : { - enabled : 0 + 'com.apple.DataProtection': { + enabled: 0 }, - "com.apple.Keychain" : { + 'com.apple.Keychain': { enabled: 1 } } @@ -444,14 +442,14 @@ exports.testWritingPBXProject = { test.done(); }, - 'should add target attribute to PBXProject TargetAttributes': function(test) { + 'should add target attribute to PBXProject TargetAttributes': function (test) { project.addTargetAttribute('ProvisioningStyle', 'Manual'); var output = project.writeSync(); test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1); test.done(); }, - 'should change target attribute at PBXProject TargetAttributes': function(test) { + 'should change target attribute at PBXProject TargetAttributes': function (test) { project.addTargetAttribute('ProvisioningStyle', 'Manual'); var output = project.writeSync(); test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1); @@ -463,7 +461,7 @@ exports.testWritingPBXProject = { test.done(); }, - 'should remove target attribute from PBXProject TargetAttributes': function(test) { + 'should remove target attribute from PBXProject TargetAttributes': function (test) { project.addTargetAttribute('ProvisioningStyle', 'Manual'); var output = project.writeSync(); test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1); @@ -474,4 +472,4 @@ exports.testWritingPBXProject = { test.done(); } -} +}; diff --git a/test/knownRegions.js b/test/knownRegions.js index 6d4a0cc..3f0c53e 100644 --- a/test/knownRegions.js +++ b/test/knownRegions.js @@ -21,74 +21,74 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var project = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { project.hash = cleanHash(); callback(); -} +}; exports.addKnownRegion = { - 'should add new region to existing knownRegions': function (test) { - var knownRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']; - test.equal(knownRegions.indexOf('Spanish'), -1); - - project.addKnownRegion('Spanish') - knownRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']; - test.notEqual(knownRegions.indexOf('Spanish'), -1); - test.done(); - }, - - 'should not add region if it already exists in knownRegions': function (test) { - var numberOfRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions'].length; - - project.addKnownRegion('German'); - var newNumberOfRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions'].length; - test.equal(numberOfRegions, newNumberOfRegions); - test.done(); - }, - - 'should create knownRegions array if it does not exist': function (test) { - delete project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']; - test.ok(!project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']); - - project.addKnownRegion('German') - test.ok(project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']); - test.done(); - }, -} + 'should add new region to existing knownRegions': function (test) { + var knownRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions; + test.equal(knownRegions.indexOf('Spanish'), -1); + + project.addKnownRegion('Spanish'); + knownRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions; + test.notEqual(knownRegions.indexOf('Spanish'), -1); + test.done(); + }, + + 'should not add region if it already exists in knownRegions': function (test) { + var numberOfRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions.length; + + project.addKnownRegion('German'); + var newNumberOfRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions.length; + test.equal(numberOfRegions, newNumberOfRegions); + test.done(); + }, + + 'should create knownRegions array if it does not exist': function (test) { + delete project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions; + test.ok(!project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions); + + project.addKnownRegion('German'); + test.ok(project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions); + test.done(); + } +}; exports.removeKnownRegion = { - 'should remove named region from knownRegions': function (test) { - var knownRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']; - test.notEqual(knownRegions.indexOf('German'), -1); - - project.removeKnownRegion('German'); - knownRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions']; - test.equal(knownRegions.indexOf('German'), -1); - test.done(); - }, - - 'should do nothing if named region does not exist in knownRegions': function (test) { - var numberOfRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions'].length; - - project.removeKnownRegion('Korean'); - var newNumberOfRegions = project.pbxProjectSection()[project.getFirstProject()['uuid']]['knownRegions'].length; - test.equal(numberOfRegions, newNumberOfRegions); - test.done(); - }, -} + 'should remove named region from knownRegions': function (test) { + var knownRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions; + test.notEqual(knownRegions.indexOf('German'), -1); + + project.removeKnownRegion('German'); + knownRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions; + test.equal(knownRegions.indexOf('German'), -1); + test.done(); + }, + + 'should do nothing if named region does not exist in knownRegions': function (test) { + var numberOfRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions.length; + + project.removeKnownRegion('Korean'); + var newNumberOfRegions = project.pbxProjectSection()[project.getFirstProject().uuid].knownRegions.length; + test.equal(numberOfRegions, newNumberOfRegions); + test.done(); + } +}; exports.hasKnownRegion = { - 'should return true if named region exists in knownRegions': function (test) { - test.ok(project.hasKnownRegion('German')); - test.done(); - }, - - 'should return false if named region does not exist in knownRegions': function (test) { - test.ok(!project.hasKnownRegion('Ducth')); - test.done(); - }, -} + 'should return true if named region exists in knownRegions': function (test) { + test.ok(project.hasKnownRegion('German')); + test.done(); + }, + + 'should return false if named region does not exist in knownRegions': function (test) { + test.ok(!project.hasKnownRegion('Ducth')); + test.done(); + } +}; diff --git a/test/multipleTargets.js b/test/multipleTargets.js index a94c8e0..3404da0 100644 --- a/test/multipleTargets.js +++ b/test/multipleTargets.js @@ -22,150 +22,139 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addFilesToTarget = { 'should add the file to a proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'file.m'; - var target = "1D6058900D05DD3D006BFB54"; - var filename = "file.m"; - - var opt = { target : target }; - var newFile = proj.addSourceFile(filename,opt); + var opt = { target: target }; + var newFile = proj.addSourceFile(filename, opt); test.equal(newFile.constructor, pbxFile); var sources = proj.pbxSourcesBuildPhaseObj(target); - test.equal(sources.files[5].comment, filename+" in Sources"); + test.equal(sources.files[5].comment, filename + ' in Sources'); test.done(); }, 'should remove the file from the proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'file.m'; - var target = "1D6058900D05DD3D006BFB54"; - var filename = "file.m"; - - var opt = { target : target }; - var newFile = proj.addSourceFile(filename,opt); + var opt = { target: target }; + var newFile = proj.addSourceFile(filename, opt); test.equal(newFile.constructor, pbxFile); var sources = proj.pbxSourcesBuildPhaseObj(target); - test.equal(sources.files[5].comment, filename+" in Sources"); + test.equal(sources.files[5].comment, filename + ' in Sources'); var l = sources.files.length; - proj.removeSourceFile(filename,opt); + proj.removeSourceFile(filename, opt); var sources = proj.pbxSourcesBuildPhaseObj(target); - test.equal(sources.files.length,l-1); + test.equal(sources.files.length, l - 1); test.done(); }, 'should fail when specifying an invalid target': function (test) { + var target = 'XXXXX'; + var filename = 'file.m'; - var target = "XXXXX"; - var filename = "file.m"; - - var opt = { target : target }; - test.throws(function(){ - proj.addSourceFile(filename,opt); + var opt = { target: target }; + test.throws(function () { + proj.addSourceFile(filename, opt); }); - test.done(); }, - 'should add the library to a proper target': function (test) { - - var target = "1D6058900D05DD3D006BFB54"; - var filename = "library.lib"; + 'should add the library to a proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'library.lib'; - var opt = { target : target }; - var newFile = proj.addStaticLibrary(filename,opt); + var opt = { target: target }; + var newFile = proj.addStaticLibrary(filename, opt); test.equal(newFile.constructor, pbxFile); var libraries = proj.pbxFrameworksBuildPhaseObj(target); - test.equal(libraries.files[4].comment, filename+" in Resources"); + test.equal(libraries.files[4].comment, filename + ' in Resources'); test.done(); }, 'should remove the library to a proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'library.lib'; - var target = "1D6058900D05DD3D006BFB54"; - var filename = "library.lib"; - - var opt = { target : target }; - var newFile = proj.addStaticLibrary(filename,opt); + var opt = { target: target }; + var newFile = proj.addStaticLibrary(filename, opt); test.equal(newFile.constructor, pbxFile); var libraries = proj.pbxFrameworksBuildPhaseObj(target); - test.equal(libraries.files[4].comment, filename+" in Resources"); + test.equal(libraries.files[4].comment, filename + ' in Resources'); var l = libraries.files.length; - proj.removeFramework(filename,opt); + proj.removeFramework(filename, opt); var libraries = proj.pbxFrameworksBuildPhaseObj(target); - test.equal(libraries.files.length,l-1); + test.equal(libraries.files.length, l - 1); test.done(); - }, - 'should add the framework to a proper target': function (test) { + 'should add the framework to a proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'delta.framework'; - var target = "1D6058900D05DD3D006BFB54"; - var filename = "delta.framework"; - - var opt = { target : target }; - var newFile = proj.addFramework(filename,opt); + var opt = { target: target }; + var newFile = proj.addFramework(filename, opt); test.equal(newFile.constructor, pbxFile); var frameworks = proj.pbxFrameworksBuildPhaseObj(target); - test.equal(frameworks.files[4].comment, filename+" in Frameworks"); + test.equal(frameworks.files[4].comment, filename + ' in Frameworks'); test.done(); }, 'should add a ressource fileto a proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'delta.png'; - var target = "1D6058900D05DD3D006BFB54"; - var filename = "delta.png"; - - var opt = { target : target }; - var newFile = proj.addResourceFile(filename,opt); + var opt = { target: target }; + var newFile = proj.addResourceFile(filename, opt); test.equal(newFile.constructor, pbxFile); var resources = proj.pbxResourcesBuildPhaseObj(target); - test.equal(resources.files[26].comment, filename+" in Resources"); + test.equal(resources.files[26].comment, filename + ' in Resources'); test.done(); }, - 'should remove a ressource file from a proper target': function (test) { + 'should remove a ressource file from a proper target': function (test) { + var target = '1D6058900D05DD3D006BFB54'; + var filename = 'delta.png'; - var target = "1D6058900D05DD3D006BFB54"; - var filename = "delta.png"; - - var opt = { target : target }; - var newFile = proj.addResourceFile(filename,opt); + var opt = { target: target }; + var newFile = proj.addResourceFile(filename, opt); test.equal(newFile.constructor, pbxFile); var resources = proj.pbxResourcesBuildPhaseObj(target); - test.equal(resources.files[26].comment, filename+" in Resources"); + test.equal(resources.files[26].comment, filename + ' in Resources'); var l = resources.files.length; - proj.removeResourceFile(filename,opt); - var resources = proj.pbxResourcesBuildPhaseObj(target); - test.equal(resources.files.length,l-1); + proj.removeResourceFile(filename, opt); + var resources = proj.pbxResourcesBuildPhaseObj(target); + test.equal(resources.files.length, l - 1); test.done(); - }, -} - + } +}; diff --git a/test/parser/build-config.js b/test/parser/build-config.js index 9bc8b54..9c2b8da 100644 --- a/test/parser/build-config.js +++ b/test/parser/build-config.js @@ -28,21 +28,21 @@ var project = rawProj.project; exports['should parse the build config section'] = function (test) { // if it gets this far it's worked test.done(); -} +}; exports['should read a decimal value correctly'] = function (test) { - var xcbConfig = project.objects['XCBuildConfiguration']; + var xcbConfig = project.objects.XCBuildConfiguration; var debugSettings = xcbConfig['1D6058950D05DD3E006BFB54'].buildSettings; - test.strictEqual(debugSettings['IPHONEOS_DEPLOYMENT_TARGET'], '3.0'); + test.strictEqual(debugSettings.IPHONEOS_DEPLOYMENT_TARGET, '3.0'); test.done(); -} +}; exports['should read an escaped value correctly'] = function (test) { - var xcbConfig = project.objects['XCBuildConfiguration']; - var debugSettings = xcbConfig['C01FCF4F08A954540054247B'].buildSettings; + var xcbConfig = project.objects.XCBuildConfiguration; + var debugSettings = xcbConfig.C01FCF4F08A954540054247B.buildSettings; var expt = '"\\"$(PHONEGAPLIB)/Classes/JSON\\" \\"$(PHONEGAPLIB)/Classes\\""'; - test.strictEqual(debugSettings['USER_HEADER_SEARCH_PATHS'], expt); + test.strictEqual(debugSettings.USER_HEADER_SEARCH_PATHS, expt); test.done(); -} +}; diff --git a/test/parser/comments.js b/test/parser/comments.js index f2a3a0e..7aed1ab 100644 --- a/test/parser/comments.js +++ b/test/parser/comments.js @@ -27,4 +27,4 @@ var parser = PEG.generate(grammar); exports['should ignore comments outside the main object'] = function (test) { parser.parse(pbx); test.done(); -} +}; diff --git a/test/parser/dotsInNames.js b/test/parser/dotsInNames.js index 232d66f..b085cb9 100644 --- a/test/parser/dotsInNames.js +++ b/test/parser/dotsInNames.js @@ -28,6 +28,6 @@ exports['should parse com.apple.BackgroundModes'] = function (test) { var targets = project.attributes.TargetAttributes['1D6058900D05DD3D006BFB54']; var backgroundModes = targets.SystemCapabilities['com.apple.BackgroundModes']; - test.deepEqual(backgroundModes, {enabled: 1}); - test.done() -} + test.deepEqual(backgroundModes, { enabled: 1 }); + test.done(); +}; diff --git a/test/parser/file-references.js b/test/parser/file-references.js index 45e46d8..36624bb 100644 --- a/test/parser/file-references.js +++ b/test/parser/file-references.js @@ -25,6 +25,6 @@ var rawProj = parser.parse(pbx); var project = rawProj.project; exports['should have a PBXFileReference section'] = function (test) { - test.ok(project.objects['PBXFileReference']); + test.ok(project.objects.PBXFileReference); test.done(); -} +}; diff --git a/test/parser/hash.js b/test/parser/hash.js index 1422cb5..a67c4d1 100644 --- a/test/parser/hash.js +++ b/test/parser/hash.js @@ -26,28 +26,28 @@ var project = rawProj.project; exports['should have the top-line comment in place'] = function (test) { test.equals(rawProj.headComment, '!$*UTF8*$!'); - test.done() -} + test.done(); +}; exports['should parse a numeric attribute'] = function (test) { test.strictEqual(project.archiveVersion, 1); test.strictEqual(project.objectVersion, 45); - test.done() -} + test.done(); +}; exports['should parse an empty object'] = function (test) { var empty = project.classes; test.equal(Object.keys(empty).length, 0); - test.done() -} + test.done(); +}; exports['should split out properties and comments'] = function (test) { test.equal(project.rootObject, '29B97313FDCFA39411CA2CEA'); - test.equal(project['rootObject_comment'], 'Project object'); + test.equal(project.rootObject_comment, 'Project object'); test.done(); -} +}; exports['should parse non-commented hash things'] = function (test) { test.equal(project.nonObject, '29B97313FDCFA39411CA2CEF'); test.done(); -} +}; diff --git a/test/parser/header-search.js b/test/parser/header-search.js index 5696f21..2e83ba9 100644 --- a/test/parser/header-search.js +++ b/test/parser/header-search.js @@ -25,10 +25,10 @@ var rawProj = parser.parse(pbx); var project = rawProj.project; exports['should read a decimal value correctly'] = function (test) { - var debug = project.objects['XCBuildConfiguration']['C01FCF4F08A954540054247B']; - var hsPaths = debug.buildSettings['HEADER_SEARCH_PATHS']; + var debug = project.objects.XCBuildConfiguration.C01FCF4F08A954540054247B; + var hsPaths = debug.buildSettings.HEADER_SEARCH_PATHS; var expected = '"\\"$(TARGET_BUILD_DIR)/usr/local/lib/include\\""'; test.equal(hsPaths[0], expected); test.done(); -} +}; diff --git a/test/parser/section-entries.js b/test/parser/section-entries.js index a55ad78..dfa2b44 100644 --- a/test/parser/section-entries.js +++ b/test/parser/section-entries.js @@ -25,19 +25,19 @@ var rawProj = parser.parse(pbx); var project = rawProj.project; exports['should have a PBXVariantGroup section'] = function (test) { - test.ok(project.objects['PBXVariantGroup']); + test.ok(project.objects.PBXVariantGroup); test.done(); -} +}; exports['should have two children for PBXVariantGroup'] = function (test) { - test.ok(project.objects['PBXVariantGroup']['1F766FDF13BBADB100FB74C0']); - test.ok(project.objects['PBXVariantGroup']['1F766FDC13BBADB100FB74C0']); + test.ok(project.objects.PBXVariantGroup['1F766FDF13BBADB100FB74C0']); + test.ok(project.objects.PBXVariantGroup['1F766FDC13BBADB100FB74C0']); test.done(); -} +}; exports['should store quote-surround values correctly'] = function (test) { - var localizable = project.objects['PBXVariantGroup']['1F766FDF13BBADB100FB74C0']; + var localizable = project.objects.PBXVariantGroup['1F766FDF13BBADB100FB74C0']; test.equal(localizable.sourceTree, '""'); test.done(); -} +}; diff --git a/test/parser/section-split.js b/test/parser/section-split.js index 39b6d1b..b411f84 100644 --- a/test/parser/section-split.js +++ b/test/parser/section-split.js @@ -25,29 +25,28 @@ var rawProj = parser.parse(pbx); var project = rawProj.project; exports['should have a PBXTargetDependency section'] = function (test) { - test.ok(project.objects['PBXTargetDependency']); - test.done(); -} + test.ok(project.objects.PBXTargetDependency); + test.done(); +}; exports['should have the right child of PBXTargetDependency section'] = function (test) { - test.ok(project.objects['PBXTargetDependency']['301BF551109A68C00062928A']); - test.done(); -} + test.ok(project.objects.PBXTargetDependency['301BF551109A68C00062928A']); + test.done(); +}; exports['should have the right properties on the dependency'] = function (test) { - var dependency = project.objects['PBXTargetDependency']['301BF551109A68C00062928A']; + var dependency = project.objects.PBXTargetDependency['301BF551109A68C00062928A']; - test.equal(dependency.isa, 'PBXTargetDependency') - test.equal(dependency.name, 'PhoneGapLib') - test.equal(dependency.targetProxy, '301BF550109A68C00062928A') - test.equal(dependency['targetProxy_comment'], 'PBXContainerItemProxy') + test.equal(dependency.isa, 'PBXTargetDependency'); + test.equal(dependency.name, 'PhoneGapLib'); + test.equal(dependency.targetProxy, '301BF550109A68C00062928A'); + test.equal(dependency.targetProxy_comment, 'PBXContainerItemProxy'); - test.done(); -} + test.done(); +}; exports['should merge two PBXTargetDependency sections'] = function (test) { - test.ok(project.objects['PBXTargetDependency']['301BF551109A68C00062928A']); - test.ok(project.objects['PBXTargetDependency']['45FDD1944D304A9F96DF3AC6']); - test.done(); -} - + test.ok(project.objects.PBXTargetDependency['301BF551109A68C00062928A']); + test.ok(project.objects.PBXTargetDependency['45FDD1944D304A9F96DF3AC6']); + test.done(); +}; diff --git a/test/parser/section.js b/test/parser/section.js index eebea10..b3724dd 100644 --- a/test/parser/section.js +++ b/test/parser/section.js @@ -25,22 +25,22 @@ var rawProj = parser.parse(pbx); var project = rawProj.project; exports['should have a PBXTargetDependency section'] = function (test) { - test.ok(project.objects['PBXTargetDependency']); + test.ok(project.objects.PBXTargetDependency); test.done(); -} +}; exports['should have the right child of PBXTargetDependency section'] = function (test) { - test.ok(project.objects['PBXTargetDependency']['301BF551109A68C00062928A']); + test.ok(project.objects.PBXTargetDependency['301BF551109A68C00062928A']); test.done(); -} +}; exports['should have the right properties on the dependency'] = function (test) { - var dependency = project.objects['PBXTargetDependency']['301BF551109A68C00062928A']; + var dependency = project.objects.PBXTargetDependency['301BF551109A68C00062928A']; - test.equal(dependency.isa, 'PBXTargetDependency') - test.equal(dependency.name, 'PhoneGapLib') - test.equal(dependency.targetProxy, '301BF550109A68C00062928A') - test.equal(dependency['targetProxy_comment'], 'PBXContainerItemProxy') + test.equal(dependency.isa, 'PBXTargetDependency'); + test.equal(dependency.name, 'PhoneGapLib'); + test.equal(dependency.targetProxy, '301BF550109A68C00062928A'); + test.equal(dependency.targetProxy_comment, 'PBXContainerItemProxy'); test.done(); -} +}; diff --git a/test/parser/two-sections.js b/test/parser/two-sections.js index 642b6c7..a3a84dd 100644 --- a/test/parser/two-sections.js +++ b/test/parser/two-sections.js @@ -27,10 +27,10 @@ var project = rawProj.project; exports['should parse a project with two sections'] = function (test) { // if it gets this far it's worked test.done(); -} +}; exports['should have both sections on the project object'] = function (test) { - test.ok(project.objects['PBXTargetDependency']); - test.ok(project.objects['PBXSourcesBuildPhase']); + test.ok(project.objects.PBXTargetDependency); + test.ok(project.objects.PBXSourcesBuildPhase); test.done(); -} +}; diff --git a/test/parser/with_array.js b/test/parser/with_array.js index 52030cd..cd5cb7d 100644 --- a/test/parser/with_array.js +++ b/test/parser/with_array.js @@ -27,31 +27,31 @@ var project = rawProj.project; exports['should parse arrays with commented entries'] = function (test) { test.ok(project.files instanceof Array); test.equal(project.files.length, 2); - test.done() -} + test.done(); +}; exports['should parse arrays with uncommented entries'] = function (test) { test.ok(project.ARCHS instanceof Array); test.equal(project.ARCHS.length, 2); - test.done() -} + test.done(); +}; exports['should parse empty arrays'] = function (test) { test.ok(project.empties instanceof Array); test.equal(project.empties.length, 0); test.done(); -} +}; exports['should be correct ordered'] = function (test) { var archs = project.ARCHS; test.equal(archs[0], 'armv6'); test.equal(archs[1], 'armv7'); test.done(); -} +}; exports['should parse values and comments correctly'] = function (test) { - var appDelegate = project.files[1] - test.equal(appDelegate.value, '1D3623260D0F684500981E51') - test.equal(appDelegate.comment, 'AppDelegate.m in Sources') - test.done() -} + var appDelegate = project.files[1]; + test.equal(appDelegate.value, '1D3623260D0F684500981E51'); + test.equal(appDelegate.comment, 'AppDelegate.m in Sources'); + test.done(); +}; diff --git a/test/pbxFile.js b/test/pbxFile.js index 8804b1d..8124f41 100644 --- a/test/pbxFile.js +++ b/test/pbxFile.js @@ -17,7 +17,7 @@ var pbxFile = require('../lib/pbxFile'); -exports['lastKnownFileType'] = { +exports.lastKnownFileType = { 'should detect that a .m path means sourcecode.c.objc': function (test) { var sourceFile = new pbxFile('Plugins/ChildBrowser.m'); @@ -83,7 +83,7 @@ exports['lastKnownFileType'] = { 'should allow lastKnownFileType to be overridden': function (test) { var sourceFile = new pbxFile('Plugins/ChildBrowser.m', - { lastKnownFileType: 'somestupidtype' }); + { lastKnownFileType: 'somestupidtype' }); test.equal('somestupidtype', sourceFile.lastKnownFileType); test.done(); @@ -95,9 +95,9 @@ exports['lastKnownFileType'] = { test.equal('unknown', sourceFile.lastKnownFileType); test.done(); } -} +}; -exports['group'] = { +exports.group = { 'should be Sources for source files': function (test) { var sourceFile = new pbxFile('Plugins/ChildBrowser.m'); @@ -142,18 +142,18 @@ exports['group'] = { test.equal('Frameworks', archive.group); test.done(); } -} +}; -exports['basename'] = { +exports.basename = { 'should be as expected': function (test) { var sourceFile = new pbxFile('Plugins/ChildBrowser.m'); test.equal('ChildBrowser.m', sourceFile.basename); test.done(); } -} +}; -exports['sourceTree'] = { +exports.sourceTree = { 'should be SDKROOT for dylibs': function (test) { var sourceFile = new pbxFile('libsqlite3.dylib'); @@ -184,7 +184,7 @@ exports['sourceTree'] = { 'should be overridable either way': function (test) { var sourceFile = new pbxFile('Plugins/ChildBrowser.m', - { sourceTree: 'SOMETHING'}); + { sourceTree: 'SOMETHING' }); test.equal('SOMETHING', sourceFile.sourceTree); test.done(); @@ -196,9 +196,9 @@ exports['sourceTree'] = { test.equal('""', archive.sourceTree); test.done(); } -} +}; -exports['path'] = { +exports.path = { 'should be "usr/lib" for dylibs (relative to SDKROOT)': function (test) { var sourceFile = new pbxFile('libsqlite3.dylib'); @@ -220,21 +220,20 @@ exports['path'] = { test.done(); }, - 'should default to the first argument otherwise': function (test) { var sourceFile = new pbxFile('Plugins/ChildBrowser.m'); test.equal('Plugins/ChildBrowser.m', sourceFile.path); test.done(); } -} +}; -exports['settings'] = { - 'should not be defined by default': function (test) { - var sourceFile = new pbxFile('social.framework'); +exports.settings = { + 'should not be defined by default': function (test) { + var sourceFile = new pbxFile('social.framework'); - test.equal(undefined, sourceFile.settings); - test.done(); + test.equal(undefined, sourceFile.settings); + test.done(); }, 'should be undefined if weak is false or non-boolean': function (test) { @@ -252,7 +251,7 @@ exports['settings'] = { var sourceFile = new pbxFile('social.framework', { weak: true }); - test.deepEqual({ATTRIBUTES:["Weak"]}, sourceFile.settings); + test.deepEqual({ ATTRIBUTES: ['Weak'] }, sourceFile.settings); test.done(); }, @@ -260,7 +259,7 @@ exports['settings'] = { var sourceFile = new pbxFile('signable.framework', { embed: true, sign: true }); - test.deepEqual({ATTRIBUTES:["CodeSignOnCopy"]}, sourceFile.settings); + test.deepEqual({ ATTRIBUTES: ['CodeSignOnCopy'] }, sourceFile.settings); test.done(); }, @@ -268,23 +267,23 @@ exports['settings'] = { var sourceFile = new pbxFile('signableWeak.framework', { embed: true, weak: true, sign: true }); - test.deepEqual({ATTRIBUTES:["Weak", "CodeSignOnCopy"]}, sourceFile.settings); + test.deepEqual({ ATTRIBUTES: ['Weak', 'CodeSignOnCopy'] }, sourceFile.settings); test.done(); }, 'should be {COMPILER_FLAGS:"blah"} if compiler flags specified': function (test) { var sourceFile = new pbxFile('Plugins/BarcodeScanner.m', - { compilerFlags: "-std=c++11 -fno-objc-arc" }); + { compilerFlags: '-std=c++11 -fno-objc-arc' }); - test.deepEqual({COMPILER_FLAGS:'"-std=c++11 -fno-objc-arc"'}, sourceFile.settings); + test.deepEqual({ COMPILER_FLAGS: '"-std=c++11 -fno-objc-arc"' }, sourceFile.settings); test.done(); }, 'should be .appex if {explicitFileType:\'"wrapper.app-extension"\'} specified': function (test) { var sourceFile = new pbxFile('AppExtension', - { explicitFileType: '"wrapper.app-extension"'}); + { explicitFileType: '"wrapper.app-extension"' }); test.equal('AppExtension.appex', sourceFile.basename); test.done(); } -} +}; diff --git a/test/pbxItemByComment.js b/test/pbxItemByComment.js index 1feebe1..7bf9a24 100644 --- a/test/pbxItemByComment.js +++ b/test/pbxItemByComment.js @@ -21,14 +21,14 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.pbxItemByComment = { 'should return PBXTargetDependency': function (test) { @@ -36,33 +36,33 @@ exports.pbxItemByComment = { test.ok(pbxItem); test.equals(pbxItem.isa, 'PBXTargetDependency'); - test.done() + test.done(); }, 'should return PBXContainerItemProxy': function (test) { var pbxItem = proj.pbxItemByComment('libPhoneGap.a', 'PBXReferenceProxy'); test.ok(pbxItem); test.equals(pbxItem.isa, 'PBXReferenceProxy'); - test.done() + test.done(); }, 'should return PBXResourcesBuildPhase': function (test) { var pbxItem = proj.pbxItemByComment('Resources', 'PBXResourcesBuildPhase'); test.ok(pbxItem); test.equals(pbxItem.isa, 'PBXResourcesBuildPhase'); - test.done() + test.done(); }, 'should return PBXShellScriptBuildPhase': function (test) { var pbxItem = proj.pbxItemByComment('Touch www folder', 'PBXShellScriptBuildPhase'); test.ok(pbxItem); test.equals(pbxItem.isa, 'PBXShellScriptBuildPhase'); - test.done() + test.done(); }, 'should return null when PBXNativeTarget not found': function (test) { var pbxItem = proj.pbxItemByComment('Invalid', 'PBXTargetDependency'); test.equal(pbxItem, null); - test.done() + test.done(); } -} +}; diff --git a/test/pbxProject.js b/test/pbxProject.js index 55333af..e68d827 100644 --- a/test/pbxProject.js +++ b/test/pbxProject.js @@ -22,7 +22,7 @@ var jsonProject = require('./fixtures/full-project'); var fs = require('fs'); var project; -exports['creation'] = { +exports.creation = { 'should create a pbxProject with the new operator': function (test) { var myProj = new pbx('test/parser/projects/hash.pbxproj'); @@ -35,27 +35,27 @@ exports['creation'] = { test.ok(myProj instanceof pbx); test.done(); } -} +}; exports['parseSync function'] = { - 'should return the hash object': function (test) { - var myProj = new pbx('test/parser/projects/hash.pbxproj'); - var projHash = myProj.parseSync(); - test.ok(projHash); - test.done(); - }, - 'should contain valid data in the returned objects hash': function (test) { - var myProj = new pbx('test/parser/projects/hash.pbxproj'); - var projHash = myProj.parseSync(); - test.ok(projHash); - - test.equal(projHash.hash.project.archiveVersion, 1); - test.equal(projHash.hash.project.objectVersion, 45); - test.equal(projHash.hash.project.nonObject, '29B97313FDCFA39411CA2CEF'); - - test.done(); - }, -} + 'should return the hash object': function (test) { + var myProj = new pbx('test/parser/projects/hash.pbxproj'); + var projHash = myProj.parseSync(); + test.ok(projHash); + test.done(); + }, + 'should contain valid data in the returned objects hash': function (test) { + var myProj = new pbx('test/parser/projects/hash.pbxproj'); + var projHash = myProj.parseSync(); + test.ok(projHash); + + test.equal(projHash.hash.project.archiveVersion, 1); + test.equal(projHash.hash.project.objectVersion, 45); + test.equal(projHash.hash.project.nonObject, '29B97313FDCFA39411CA2CEF'); + + test.done(); + } +}; exports['parse function'] = { 'should emit an "end" event': function (test) { @@ -63,22 +63,22 @@ exports['parse function'] = { myProj.parse().on('end', function (err, projHash) { test.done(); - }) + }); }, 'should take the end callback as a parameter': function (test) { var myProj = new pbx('test/parser/projects/hash.pbxproj'); myProj.parse(function (err, projHash) { test.done(); - }) + }); }, 'should allow evented error handling': function (test) { var myProj = new pbx('NotARealPath.pbxproj'); myProj.parse().on('error', function (err) { - test.equal(typeof err, "object"); + test.equal(typeof err, 'object'); test.done(); - }) + }); }, 'should pass the hash object to the callback function': function (test) { var myProj = new pbx('test/parser/projects/hash.pbxproj'); @@ -86,7 +86,7 @@ exports['parse function'] = { myProj.parse(function (err, projHash) { test.ok(projHash); test.done(); - }) + }); }, 'should handle projects with comments in the header': function (test) { var myProj = new pbx('test/parser/projects/comments.pbxproj'); @@ -94,7 +94,7 @@ exports['parse function'] = { myProj.parse(function (err, projHash) { test.ok(projHash); test.done(); - }) + }); }, 'should attach the hash object to the pbx object': function (test) { var myProj = new pbx('test/parser/projects/hash.pbxproj'); @@ -102,7 +102,7 @@ exports['parse function'] = { myProj.parse(function (err, projHash) { test.ok(myProj.hash); test.done(); - }) + }); }, 'it should pass an error object back when the parsing fails': function (test) { var myProj = new pbx('test/parser/projects/fail.pbxproj'); @@ -110,22 +110,22 @@ exports['parse function'] = { myProj.parse(function (err, projHash) { test.ok(err); test.done(); - }) + }); } -} +}; exports['allUuids function'] = { - 'should return the right amount of uuids': function (test) { - var project = new pbx('.'); - var uuids; + 'should return the right amount of uuids': function (test) { + var project = new pbx('.'); + var uuids; - project.hash = buildConfig; - uuids = project.allUuids(); + project.hash = buildConfig; + uuids = project.allUuids(); - test.equal(uuids.length, 4); - test.done(); - } -} + test.equal(uuids.length, 4); + test.done(); + } +}; exports['generateUuid function'] = { 'should return a 24 character string': function (test) { @@ -149,63 +149,63 @@ exports['generateUuid function'] = { test.ok(uHex.test(newUUID)); test.done(); } -} +}; var bcpbx = 'test/parser/projects/build-config.pbxproj'; var original_pbx = fs.readFileSync(bcpbx, 'utf-8'); exports['updateProductName function'] = { - setUp:function(callback) { + setUp: function (callback) { callback(); }, - tearDown:function(callback) { + tearDown: function (callback) { fs.writeFileSync(bcpbx, original_pbx, 'utf-8'); callback(); }, 'should change the PRODUCT_NAME field in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.updateProductName('furious anger'); var newContents = myProj.writeSync(); test.ok(newContents.match(/PRODUCT_NAME\s*=\s*"furious anger"/)); test.done(); }); } -} +}; exports['updateBuildProperty function'] = { - setUp:function(callback) { + setUp: function (callback) { callback(); }, - tearDown:function(callback) { + tearDown: function (callback) { fs.writeFileSync(bcpbx, original_pbx, 'utf-8'); callback(); }, 'should change build properties in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.updateBuildProperty('TARGETED_DEVICE_FAMILY', '"arm"'); var newContents = myProj.writeSync(); test.ok(newContents.match(/TARGETED_DEVICE_FAMILY\s*=\s*"arm"/)); - myProj.updateBuildProperty('OTHER_LDFLAGS', ['T','E','S','T']); + myProj.updateBuildProperty('OTHER_LDFLAGS', ['T', 'E', 'S', 'T']); newContents = myProj.writeSync(); - test.ok(newContents.match(/OTHER_LDFLAGS\s*=\s*\(\s*T,\s*E,\s*S,\s*T,\s*\)/)) + test.ok(newContents.match(/OTHER_LDFLAGS\s*=\s*\(\s*T,\s*E,\s*S,\s*T,\s*\)/)); test.done(); }); } -} +}; exports['addBuildProperty function'] = { - setUp:function(callback) { + setUp: function (callback) { callback(); }, - tearDown:function(callback) { + tearDown: function (callback) { fs.writeFileSync(bcpbx, original_pbx, 'utf-8'); callback(); }, 'should add 4 build properties in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.addBuildProperty('ENABLE_BITCODE', 'NO'); var newContents = myProj.writeSync(); test.equal(newContents.match(/ENABLE_BITCODE\s*=\s*NO/g).length, 4); @@ -214,7 +214,7 @@ exports['addBuildProperty function'] = { }, 'should add 2 build properties in the .pbxproj file for specific build': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.addBuildProperty('ENABLE_BITCODE', 'NO', 'Release'); var newContents = myProj.writeSync(); test.equal(newContents.match(/ENABLE_BITCODE\s*=\s*NO/g).length, 2); @@ -223,26 +223,26 @@ exports['addBuildProperty function'] = { }, 'should not add build properties in the .pbxproj file for nonexist build': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.addBuildProperty('ENABLE_BITCODE', 'NO', 'nonexist'); var newContents = myProj.writeSync(); test.ok(!newContents.match(/ENABLE_BITCODE\s*=\s*NO/g)); test.done(); }); } -} +}; exports['removeBuildProperty function'] = { - setUp:function(callback) { + setUp: function (callback) { callback(); }, - tearDown:function(callback) { + tearDown: function (callback) { fs.writeFileSync(bcpbx, original_pbx, 'utf-8'); callback(); }, 'should remove all build properties in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.removeBuildProperty('IPHONEOS_DEPLOYMENT_TARGET'); var newContents = myProj.writeSync(); test.ok(!newContents.match(/IPHONEOS_DEPLOYMENT_TARGET/)); @@ -251,7 +251,7 @@ exports['removeBuildProperty function'] = { }, 'should remove specific build properties in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.removeBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', 'Debug'); var newContents = myProj.writeSync(); test.equal(newContents.match(/IPHONEOS_DEPLOYMENT_TARGET/g).length, 2); @@ -260,7 +260,7 @@ exports['removeBuildProperty function'] = { }, 'should not remove any build properties in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.removeBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', 'notexist'); var newContents = myProj.writeSync(); test.equal(newContents.match(/IPHONEOS_DEPLOYMENT_TARGET/g).length, 4); @@ -269,7 +269,7 @@ exports['removeBuildProperty function'] = { }, 'should fine with remove inexist build properties in the .pbxproj file': function (test) { var myProj = new pbx('test/parser/projects/build-config.pbxproj'); - myProj.parse(function(err, hash) { + myProj.parse(function (err, hash) { myProj.removeBuildProperty('ENABLE_BITCODE'); var newContents = myProj.writeSync(); test.ok(!newContents.match(/ENABLE_BITCODE/)); @@ -277,7 +277,7 @@ exports['removeBuildProperty function'] = { }); } -} +}; exports['productName field'] = { 'should return the product name': function (test) { @@ -287,7 +287,7 @@ exports['productName field'] = { test.equal(newProj.productName, 'KitchenSinktablet'); test.done(); } -} +}; exports['addPluginFile function'] = { 'should strip the Plugin path prefix': function (test) { @@ -309,23 +309,23 @@ exports['addPluginFile function'] = { test.done(); }); } -} +}; -exports['hasFile'] = { +exports.hasFile = { 'should return true if the file is in the project': function (test) { var newProj = new pbx('.'); newProj.hash = jsonProject; // sourceTree: '""' - test.ok(newProj.hasFile('AppDelegate.m')) - test.done() + test.ok(newProj.hasFile('AppDelegate.m')); + test.done(); }, 'should return false if the file is not in the project': function (test) { var newProj = new pbx('.'); newProj.hash = jsonProject; // sourceTree: '""' - test.ok(!newProj.hasFile('NotTheAppDelegate.m')) - test.done() + test.ok(!newProj.hasFile('NotTheAppDelegate.m')); + test.done(); } -} +}; diff --git a/test/pbxTargetByName.js b/test/pbxTargetByName.js index 923b7ff..e28b2a1 100644 --- a/test/pbxTargetByName.js +++ b/test/pbxTargetByName.js @@ -21,14 +21,14 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.pbxTargetByName = { 'should return PBXNativeTarget': function (test) { @@ -36,12 +36,12 @@ exports.pbxTargetByName = { test.ok(pbxTarget); test.equals(pbxTarget.isa, 'PBXNativeTarget'); - test.done() + test.done(); }, 'should return null when PBXNativeTarget not found': function (test) { var pbxTarget = proj.pbxTargetByName('Invalid'); test.equal(pbxTarget, null); - test.done() + test.done(); } -} +}; diff --git a/test/pbxWriter.js b/test/pbxWriter.js index 3b68396..7da615c 100644 --- a/test/pbxWriter.js +++ b/test/pbxWriter.js @@ -20,7 +20,7 @@ var pbx = require('../lib/pbxProject'); var fs = require('fs'); var myProj; -function testProjectContents(filename, test, expectedFilename) { +function testProjectContents (filename, test, expectedFilename) { var myProj = new pbx(filename); var content; @@ -30,7 +30,7 @@ function testProjectContents(filename, test, expectedFilename) { content = fs.readFileSync(filename, 'utf-8'); } // normalize tabs vs strings - content = content.replace(/ /g, '\t'); + content = content.replace(/ {4}/g, '\t'); myProj.parse(function (err, projHash) { var written = myProj.writeSync(); @@ -41,23 +41,23 @@ function testProjectContents(filename, test, expectedFilename) { } // for debugging failing tests -function testContentsInDepth(filename, test) { +function testContentsInDepth (filename, test) { var myProj = new pbx(filename); var content = fs.readFileSync(filename, 'utf-8'); // normalize tabs vs strings - content = content.replace(/ /g, '\t'); + content = content.replace(/ {4}/g, '\t'); myProj.parse(function (err, projHash) { var written = myProj.writeSync(); var writtenLines = written.split('\n'); - contentLines = content.split('\n') + contentLines = content.split('\n'); test.equal(writtenLines.length, contentLines.length); - for (var i=0; i -1) - continue; + if (ref.indexOf('_comment') > -1) { continue; } refSettings = config[ref].buildSettings; - if (refSettings.PRODUCT_NAME != PRODUCT_NAME) - continue; + if (refSettings.PRODUCT_NAME != PRODUCT_NAME) { continue; } lib = refSettings.LIBRARY_SEARCH_PATHS; test.equal(lib[1], expected); @@ -59,7 +57,7 @@ exports.addAndRemoveToFromLibrarySearchPaths = { test.done(); }, - 'remove should remove from the path to each configuration section':function(test) { + 'remove should remove from the path to each configuration section': function (test) { var config; var ref; var lib; @@ -77,4 +75,4 @@ exports.addAndRemoveToFromLibrarySearchPaths = { } test.done(); } -} +}; From f633b48a63d9733710f76781915374a2225ebfe6 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 17:31:45 +0900 Subject: [PATCH 04/22] chore: disable eslint rule new-cap --- .eslintrc.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintrc.yml b/.eslintrc.yml index bedf0b7..b8e7700 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -20,3 +20,6 @@ extends: '@cordova/eslint-config/node' # This will ignore the parser that is generated by pegjs ignorePatterns: ['lib/parser/'] + +rules: + new-cap: off From 277c8365aee9d1c8496644a6ad1973e11c6eb035 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 17:32:36 +0900 Subject: [PATCH 05/22] chore: fix eslint eqeqeq problems --- lib/pbxFile.js | 6 +-- lib/pbxProject.js | 84 ++++++++++++++++++------------------ lib/pbxWriter.js | 2 +- test/BuildSettings.js | 4 +- test/FrameworkSearchPaths.js | 6 +-- test/HeaderSearchPaths.js | 8 ++-- test/LibrarySearchPaths.js | 8 ++-- test/OtherLinkerFlags.js | 6 +-- test/addStaticLibrary.js | 2 +- test/group.js | 2 +- test/removeFramework.js | 4 +- test/xcode5searchPaths.js | 6 +-- 12 files changed, 69 insertions(+), 69 deletions(-) diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 3726b1b..9d86470 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -86,7 +86,7 @@ var ENCODING_BY_FILETYPE = { }; function unquoted (text) { - return text == null ? '' : text.replace(/(^")|("$)/g, ''); + return text === null ? '' : text.replace(/(^")|("$)/g, ''); } function detectType (filePath) { @@ -101,7 +101,7 @@ function detectType (filePath) { } function defaultExtension (fileRef) { - var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE + var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType !== DEFAULT_FILETYPE ? fileRef.lastKnownFileType : fileRef.explicitFileType; for (var extension in FILETYPE_BY_EXTENSION) { @@ -192,7 +192,7 @@ function pbxFile (filepath, opt) { this.group = detectGroup(this, opt); // for custom frameworks - if (opt.customFramework == true) { + if (opt.customFramework === true) { this.customFramework = true; this.dirname = path.dirname(filepath).replace(/\\/g, '/'); } diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 899df16..c1ca62d 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -41,7 +41,7 @@ pbxProject.prototype.parse = function (cb) { var worker = fork(__dirname + '/parseJob.js', [this.filepath]); worker.on('message', function (msg) { - if (msg.name == 'SyntaxError' || msg.code) { + if (msg.name === 'SyntaxError' || msg.code) { this.emit('error', msg); } else { this.hash = msg; @@ -80,7 +80,7 @@ pbxProject.prototype.allUuids = function () { } uuids = uuids.filter(function (str) { - return !COMMENT_KEY.test(str) && str.length == 24; + return !COMMENT_KEY.test(str) && str.length === 24; }); return uuids; @@ -306,8 +306,8 @@ pbxProject.prototype.removeResourceFile = function (path, opt, group) { }; pbxProject.prototype.addFramework = function (fpath, opt) { - var customFramework = opt && opt.customFramework == true; - var link = !opt || (opt.link == undefined || opt.link); // defaults to true if not specified + var customFramework = opt && opt.customFramework === true; + var link = !opt || (opt.link === undefined || opt.link); // defaults to true if not specified var embed = opt && opt.embed; // defaults to false if not specified if (opt) { @@ -424,7 +424,7 @@ pbxProject.prototype.removeCopyfile = function (fpath, opt) { pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function (file) { var sources = this.pbxCopyfilesBuildPhaseObj(file.target); for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { + if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; } @@ -471,7 +471,7 @@ pbxProject.prototype.removeFromPbxBuildFileSection = function (file) { var uuid; for (uuid in this.pbxBuildFileSection()) { - if (this.pbxBuildFileSection()[uuid].fileRef_comment == file.basename) { + if (this.pbxBuildFileSection()[uuid].fileRef_comment === file.basename) { file.uuid = uuid; delete this.pbxBuildFileSection()[uuid]; @@ -543,7 +543,7 @@ pbxProject.prototype.removePbxGroup = function (groupName) { // only look for comments if (!COMMENT_KEY.test(key)) continue; - if (section[key] == groupName) { + if (section[key] === groupName) { itemKey = key.split(COMMENT_KEY)[0]; delete section[itemKey]; } @@ -577,17 +577,17 @@ pbxProject.prototype.removeFromPbxFileReferenceSection = function (file) { var i; var refObj = pbxFileReferenceObj(file); for (i in this.pbxFileReferenceSection()) { - if (this.pbxFileReferenceSection()[i].name == refObj.name || - ('"' + this.pbxFileReferenceSection()[i].name + '"') == refObj.name || - this.pbxFileReferenceSection()[i].path == refObj.path || - ('"' + this.pbxFileReferenceSection()[i].path + '"') == refObj.path) { + if (this.pbxFileReferenceSection()[i].name === refObj.name || + ('"' + this.pbxFileReferenceSection()[i].name + '"') === refObj.name || + this.pbxFileReferenceSection()[i].path === refObj.path || + ('"' + this.pbxFileReferenceSection()[i].path + '"') === refObj.path) { file.fileRef = file.uuid = i; delete this.pbxFileReferenceSection()[i]; break; } } var commentKey = f('%s_comment', file.fileRef); - if (this.pbxFileReferenceSection()[commentKey] != undefined) { + if (this.pbxFileReferenceSection()[commentKey] !== undefined) { delete this.pbxFileReferenceSection()[commentKey]; } @@ -631,8 +631,8 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function (file) { var pluginsGroupChildren = this.pbxGroupByName('Plugins').children; var i; for (i in pluginsGroupChildren) { - if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && - pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { + if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && + pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); break; } @@ -655,8 +655,8 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function (file) { var pluginsGroupChildren = this.pbxGroupByName('Resources').children; var i; for (i in pluginsGroupChildren) { - if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && - pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { + if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && + pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); break; } @@ -679,8 +679,8 @@ pbxProject.prototype.removeFromFrameworksPbxGroup = function (file) { var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; for (i in pluginsGroupChildren) { - if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && - pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { + if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && + pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); break; } @@ -699,7 +699,7 @@ pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { if (sources) { var files = []; for (i in sources.files) { - if (sources.files[i].comment != longComment(file)) { + if (sources.files[i].comment !== longComment(file)) { files.push(sources.files[i]); } } @@ -723,8 +723,8 @@ pbxProject.prototype.removeFromProductsPbxGroup = function (file) { var productsGroupChildren = this.pbxGroupByName('Products').children; var i; for (i in productsGroupChildren) { - if (pbxGroupChild(file).value == productsGroupChildren[i].value && - pbxGroupChild(file).comment == productsGroupChildren[i].comment) { + if (pbxGroupChild(file).value === productsGroupChildren[i].value && + pbxGroupChild(file).comment === productsGroupChildren[i].comment) { productsGroupChildren.splice(i, 1); break; } @@ -740,7 +740,7 @@ pbxProject.prototype.removeFromPbxSourcesBuildPhase = function (file) { var sources = this.pbxSourcesBuildPhaseObj(file.target); var i; for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { + if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; } @@ -757,7 +757,7 @@ pbxProject.prototype.removeFromPbxResourcesBuildPhase = function (file) { var i; for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { + if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; } @@ -772,7 +772,7 @@ pbxProject.prototype.addToPbxFrameworksBuildPhase = function (file) { pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function (file) { var sources = this.pbxFrameworksBuildPhaseObj(file.target); for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { + if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; } @@ -987,7 +987,7 @@ pbxProject.prototype.pbxGroupByName = function (name) { // only look for comments if (!COMMENT_KEY.test(key)) continue; - if (groups[key] == name) { + if (groups[key] === name) { groupKey = key.split(COMMENT_KEY)[0]; return groups[groupKey]; } @@ -1025,7 +1025,7 @@ pbxProject.prototype.pbxItemByComment = function (name, pbxSectionName) { // only look for comments if (!COMMENT_KEY.test(key)) continue; - if (section[key] == name) { + if (section[key] === name) { itemKey = key.split(COMMENT_KEY)[0]; return section[itemKey]; } @@ -1061,7 +1061,7 @@ pbxProject.prototype.buildPhase = function (group, target) { var buildPhases = nativeTarget.buildPhases; for (var i in buildPhases) { var buildPhase = buildPhases[i]; - if (buildPhase.comment == group) { return buildPhase.value + '_comment'; } + if (buildPhase.comment === group) { return buildPhase.value + '_comment'; } } }; @@ -1077,8 +1077,8 @@ pbxProject.prototype.buildPhaseObject = function (name, group, target) { if (!COMMENT_KEY.test(key)) continue; // select the proper buildPhase - if (buildPhase && buildPhase != key) { continue; } - if (section[key] == group) { + if (buildPhase && buildPhase !== key) { continue; } + if (section[key] === group) { sectionKey = key.split(COMMENT_KEY)[0]; return section[sectionKey]; } @@ -1147,7 +1147,7 @@ pbxProject.prototype.removeFromFrameworkSearchPaths = function (file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } searchPaths = buildSettings[SEARCH_PATHS]; @@ -1173,7 +1173,7 @@ pbxProject.prototype.addToFrameworkSearchPaths = function (file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } if (!buildSettings.FRAMEWORK_SEARCH_PATHS || buildSettings.FRAMEWORK_SEARCH_PATHS === INHERITED) { @@ -1196,7 +1196,7 @@ pbxProject.prototype.removeFromLibrarySearchPaths = function (file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } searchPaths = buildSettings[SEARCH_PATHS]; @@ -1222,7 +1222,7 @@ pbxProject.prototype.addToLibrarySearchPaths = function (file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } if (!buildSettings.LIBRARY_SEARCH_PATHS || buildSettings.LIBRARY_SEARCH_PATHS === INHERITED) { @@ -1249,7 +1249,7 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function (file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } if (buildSettings[SEARCH_PATHS]) { var matches = buildSettings[SEARCH_PATHS].filter(function (p) { @@ -1272,7 +1272,7 @@ pbxProject.prototype.addToHeaderSearchPaths = function (file) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } if (!buildSettings.HEADER_SEARCH_PATHS) { buildSettings.HEADER_SEARCH_PATHS = [INHERITED]; @@ -1296,7 +1296,7 @@ pbxProject.prototype.addToOtherLinkerFlags = function (flag) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { continue; } + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } if (!buildSettings[OTHER_LDFLAGS] || buildSettings[OTHER_LDFLAGS] === INHERITED) { @@ -1316,7 +1316,7 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { for (config in configurations) { buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings.PRODUCT_NAME) != this.productName) { + if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } @@ -1380,7 +1380,7 @@ pbxProject.prototype.hasFile = function (filePath) { var id; for (id in files) { file = files[id]; - if (file.path == filePath || file.path == ('"' + filePath + '"')) { + if (file.path === filePath || file.path === ('"' + filePath + '"')) { return file; } } @@ -1654,7 +1654,7 @@ function searchPathForFile (file, proj) { var pluginsPath = plugins ? plugins.path : null; var fileDir = path.dirname(file.path); - if (fileDir == '.') { + if (fileDir === '.') { fileDir = ''; } else { fileDir = '/' + fileDir; @@ -1856,8 +1856,8 @@ pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, group var groupChildren = group.children; var i; for (i in groupChildren) { - if (pbxGroupChild(file).value == groupChildren[i].value && - pbxGroupChild(file).comment == groupChildren[i].comment) { + if (pbxGroupChild(file).value === groupChildren[i].value && + pbxGroupChild(file).comment === groupChildren[i].comment) { groupChildren.splice(i, 1); break; } @@ -2071,7 +2071,7 @@ pbxProject.prototype.addDataModelDocument = function (filePath, group, opt) { var modelFileName = modelFiles[index]; var modelFilePath = path.join(filePath, modelFileName); - if (modelFileName == '.xccurrentversion') { + if (modelFileName === '.xccurrentversion') { currentVersionName = plist.readFileSync(modelFilePath)._XCCurrentVersionName; continue; } diff --git a/lib/pbxWriter.js b/lib/pbxWriter.js index 80782de..0fe289a 100644 --- a/lib/pbxWriter.js +++ b/lib/pbxWriter.js @@ -244,7 +244,7 @@ pbxWriter.prototype.writeSection = function (section) { cmt = comment(key, section); obj = section[key]; - if (obj.isa == 'PBXBuildFile' || obj.isa == 'PBXFileReference') { + if (obj.isa === 'PBXBuildFile' || obj.isa === 'PBXFileReference') { this.writeInlineObject(key, cmt, obj); } else { if (cmt) { diff --git a/test/BuildSettings.js b/test/BuildSettings.js index e5a7998..759530e 100644 --- a/test/BuildSettings.js +++ b/test/BuildSettings.js @@ -40,7 +40,7 @@ exports.addAndRemoveToFromBuildSettings = { proj.addToBuildSettings(buildSetting, value); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; test.ok(config[ref].buildSettings[buildSetting] === value); } test.done(); @@ -51,7 +51,7 @@ exports.addAndRemoveToFromBuildSettings = { proj.removeFromBuildSettings(buildSetting); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; test.ok(!config[ref].buildSettings.hasOwnProperty(buildSetting)); } test.done(); diff --git a/test/FrameworkSearchPaths.js b/test/FrameworkSearchPaths.js index ff69a54..b9c4b26 100644 --- a/test/FrameworkSearchPaths.js +++ b/test/FrameworkSearchPaths.js @@ -43,7 +43,7 @@ exports.addAndRemoveToFromFrameworkSearchPaths = { proj.addToFrameworkSearchPaths(pbxFile); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.FRAMEWORK_SEARCH_PATHS; test.ok(lib[1].indexOf('some/path') > -1); } @@ -54,10 +54,10 @@ exports.addAndRemoveToFromFrameworkSearchPaths = { proj.removeFromFrameworkSearchPaths(pbxFile); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.FRAMEWORK_SEARCH_PATHS; test.ok(lib.length === 1); - test.ok(lib[0].indexOf('some/path') == -1); + test.ok(lib[0].indexOf('some/path') === -1); } test.done(); } diff --git a/test/HeaderSearchPaths.js b/test/HeaderSearchPaths.js index bdf9098..3fe7885 100644 --- a/test/HeaderSearchPaths.js +++ b/test/HeaderSearchPaths.js @@ -40,7 +40,7 @@ exports.addAndRemoveToFromHeaderSearchPaths = { }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.HEADER_SEARCH_PATHS; test.ok(lib[1].indexOf('$(SRCROOT)/KitchenSinktablet/some/path') > -1); } @@ -51,7 +51,7 @@ exports.addAndRemoveToFromHeaderSearchPaths = { proj.addToHeaderSearchPaths(includePath); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.HEADER_SEARCH_PATHS; test.ok(lib[1].indexOf(includePath) > -1); } @@ -67,10 +67,10 @@ exports.addAndRemoveToFromHeaderSearchPaths = { }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.HEADER_SEARCH_PATHS; test.ok(lib.length === 1); - test.ok(lib[0].indexOf('$(SRCROOT)/KitchenSinktablet/some/path/include') == -1); + test.ok(lib[0].indexOf('$(SRCROOT)/KitchenSinktablet/some/path/include') === -1); } test.done(); } diff --git a/test/LibrarySearchPaths.js b/test/LibrarySearchPaths.js index 4b8f6f4..6f0aecb 100644 --- a/test/LibrarySearchPaths.js +++ b/test/LibrarySearchPaths.js @@ -40,7 +40,7 @@ exports.addAndRemoveToFromLibrarySearchPaths = { }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.LIBRARY_SEARCH_PATHS; test.ok(lib[1].indexOf('$(SRCROOT)/KitchenSinktablet/some/path') > -1); } @@ -51,7 +51,7 @@ exports.addAndRemoveToFromLibrarySearchPaths = { proj.addToLibrarySearchPaths(libPath); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.LIBRARY_SEARCH_PATHS; test.ok(lib[1].indexOf(libPath) > -1); } @@ -67,10 +67,10 @@ exports.addAndRemoveToFromLibrarySearchPaths = { }); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.LIBRARY_SEARCH_PATHS; test.ok(lib.length === 1); - test.ok(lib[0].indexOf('$(SRCROOT)/KitchenSinktablet/some/path') == -1); + test.ok(lib[0].indexOf('$(SRCROOT)/KitchenSinktablet/some/path') === -1); } test.done(); } diff --git a/test/OtherLinkerFlags.js b/test/OtherLinkerFlags.js index d8e1460..b72e203 100644 --- a/test/OtherLinkerFlags.js +++ b/test/OtherLinkerFlags.js @@ -39,7 +39,7 @@ exports.addAndRemoveToFromOtherLinkerFlags = { proj.addToOtherLinkerFlags(flag); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.OTHER_LDFLAGS; test.ok(lib[1].indexOf(flag) > -1); } @@ -51,10 +51,10 @@ exports.addAndRemoveToFromOtherLinkerFlags = { proj.removeFromOtherLinkerFlags(flag); var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; var lib = config[ref].buildSettings.OTHER_LDFLAGS; test.ok(lib.length === 1); - test.ok(lib[0].indexOf(flag) == -1); + test.ok(lib[0].indexOf(flag) === -1); } test.done(); } diff --git a/test/addStaticLibrary.js b/test/addStaticLibrary.js index 1131b7d..d42446f 100644 --- a/test/addStaticLibrary.js +++ b/test/addStaticLibrary.js @@ -176,7 +176,7 @@ exports.addStaticLibrary = { for (i = 0; i < ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; - if (buildSettings.PRODUCT_NAME == '"KitchenSinktablet"') { + if (buildSettings.PRODUCT_NAME === '"KitchenSinktablet"') { test.ok(buildSettings.LIBRARY_SEARCH_PATHS); } } diff --git a/test/group.js b/test/group.js index 65323cb..fda8b0f 100644 --- a/test/group.js +++ b/test/group.js @@ -401,7 +401,7 @@ exports.validatePropReplaceFix = { exports.validateHasFile = { 'should return true for has file MainViewController.m': function (test) { var result = project.hasFile('MainViewController.m'); - test.ok(result.path == 'MainViewController.m'); + test.ok(result.path === 'MainViewController.m'); test.done(); } }; diff --git a/test/removeFramework.js b/test/removeFramework.js index 7f59947..8252532 100644 --- a/test/removeFramework.js +++ b/test/removeFramework.js @@ -166,7 +166,7 @@ exports.removeFramework = { for (i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; - test.ok(current.indexOf(expectedPath) == -1); + test.ok(current.indexOf(expectedPath) === -1); } test.done(); @@ -193,7 +193,7 @@ exports.removeFramework = { for (i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; - test.ok(current.indexOf(expectedPath) == -1); + test.ok(current.indexOf(expectedPath) === -1); } test.done(); diff --git a/test/xcode5searchPaths.js b/test/xcode5searchPaths.js index 9351bf8..7f5abb3 100644 --- a/test/xcode5searchPaths.js +++ b/test/xcode5searchPaths.js @@ -49,7 +49,7 @@ exports.addAndRemoveToFromLibrarySearchPaths = { refSettings = config[ref].buildSettings; - if (refSettings.PRODUCT_NAME != PRODUCT_NAME) { continue; } + if (refSettings.PRODUCT_NAME !== PRODUCT_NAME) { continue; } lib = refSettings.LIBRARY_SEARCH_PATHS; test.equal(lib[1], expected); @@ -67,11 +67,11 @@ exports.addAndRemoveToFromLibrarySearchPaths = { config = proj.pbxXCBuildConfigurationSection(); for (ref in config) { - if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME != PRODUCT_NAME) continue; + if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; lib = config[ref].buildSettings.LIBRARY_SEARCH_PATHS; test.ok(lib.length === 1); - test.ok(lib[0].indexOf('$(SRCROOT)/KitchenSinktablet/some/path') == -1); + test.ok(lib[0].indexOf('$(SRCROOT)/KitchenSinktablet/some/path') === -1); } test.done(); } From e79178ef5b319801b8d2b776349a381be57c0620 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:00:22 +0900 Subject: [PATCH 06/22] chore: fix eslint no-unused-vars problems --- lib/pbxFile.js | 11 ----------- lib/pbxProject.js | 26 -------------------------- lib/pbxWriter.js | 3 --- test/BuildSettings.js | 1 - test/HeaderSearchPaths.js | 1 - test/LibrarySearchPaths.js | 1 - test/OtherLinkerFlags.js | 1 - test/addBuildPhase.js | 27 +++++++++++++-------------- test/addFramework.js | 12 ++++++------ test/addHeaderFile.js | 6 +++--- test/addRemovePbxGroup.js | 16 ++++++++-------- test/addResourceFile.js | 14 +++++++------- test/addSourceFile.js | 8 ++++---- test/addStaticLibrary.js | 19 +++++++++---------- test/dataModelDocument.js | 8 ++++---- test/group.js | 5 ++--- test/parser/build-config.js | 1 - test/pbxProject.js | 1 - test/pbxWriter.js | 34 ++++++++++++---------------------- test/removeFramework.js | 16 ++++++++-------- test/removeHeaderFile.js | 4 ++-- test/removeResourceFile.js | 8 ++++---- test/removeSourceFile.js | 8 ++++---- test/variantGroup.js | 29 +---------------------------- test/xcode5searchPaths.js | 1 - 25 files changed, 87 insertions(+), 174 deletions(-) diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 9d86470..17a2811 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -20,7 +20,6 @@ var path = require('path'); var util = require('util'); var DEFAULT_SOURCETREE = '""'; var DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR'; -var DEFAULT_FILEENCODING = 4; var DEFAULT_GROUP = 'Resources'; var DEFAULT_FILETYPE = 'unknown'; @@ -174,16 +173,6 @@ function defaultPath (fileRef, filePath) { return filePath; } -function defaultGroup (fileRef) { - var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType]; - - if (!groupName) { - return DEFAULT_GROUP; - } - - return defaultGroup; -} - function pbxFile (filepath, opt) { var opt = opt || {}; diff --git a/lib/pbxProject.js b/lib/pbxProject.js index c1ca62d..0fb79eb 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -353,8 +353,6 @@ pbxProject.prototype.addFramework = function (fpath, opt) { }; pbxProject.prototype.removeFramework = function (fpath, opt) { - var embed = opt && opt.embed; - if (opt) { delete opt.embed; } @@ -1067,7 +1065,6 @@ pbxProject.prototype.buildPhase = function (group, target) { pbxProject.prototype.buildPhaseObject = function (name, group, target) { var section = this.hash.project.objects[name]; - var obj; var sectionKey; var key; var buildPhase = this.buildPhase(group, target); @@ -1137,7 +1134,6 @@ pbxProject.prototype.updateProductName = function (name) { pbxProject.prototype.removeFromFrameworkSearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; var SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS'; var config; var buildSettings; @@ -1168,7 +1164,6 @@ pbxProject.prototype.addToFrameworkSearchPaths = function (file) { var INHERITED = '"$(inherited)"'; var config; var buildSettings; - var searchPaths; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1186,7 +1181,6 @@ pbxProject.prototype.addToFrameworkSearchPaths = function (file) { pbxProject.prototype.removeFromLibrarySearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; var SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS'; var config; var buildSettings; @@ -1217,7 +1211,6 @@ pbxProject.prototype.addToLibrarySearchPaths = function (file) { var INHERITED = '"$(inherited)"'; var config; var buildSettings; - var searchPaths; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1239,11 +1232,9 @@ pbxProject.prototype.addToLibrarySearchPaths = function (file) { pbxProject.prototype.removeFromHeaderSearchPaths = function (file) { var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; var SEARCH_PATHS = 'HEADER_SEARCH_PATHS'; var config; var buildSettings; - var searchPaths; var new_path = searchPathForFile(file, this); for (config in configurations) { @@ -1267,7 +1258,6 @@ pbxProject.prototype.addToHeaderSearchPaths = function (file) { var INHERITED = '"$(inherited)"'; var config; var buildSettings; - var searchPaths; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1445,7 +1435,6 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { var productType = producttypeForTargettype(targetType); var productFileType = filetypeForProducttype(productType); var productFile = this.addProductFile(productName, { group: 'Copy Files', target: targetUuid, explicitFileType: productFileType }); - var productFileName = productFile.basename; // Product: Add to build file list this.addToPbxBuildFileSection(productFile); @@ -1637,10 +1626,6 @@ function correctForResourcesPath (file, project) { return correctForPath(file, project, 'Resources'); } -function correctForFrameworksPath (file, project) { - return correctForPath(file, project, 'Frameworks'); -} - function correctForPath (file, project, group) { var r_group_dir = new RegExp('^' + group + '[\\\\/]'); @@ -1687,17 +1672,6 @@ function unquote (str) { if (str) return str.replace(/^"(.*)"$/, '$1'); } -function buildPhaseNameForIsa (isa) { - BUILDPHASENAME_BY_ISA = { - PBXCopyFilesBuildPhase: 'Copy Files', - PBXResourcesBuildPhase: 'Resources', - PBXSourcesBuildPhase: 'Sources', - PBXFrameworksBuildPhase: 'Frameworks' - }; - - return BUILDPHASENAME_BY_ISA[isa]; -} - function producttypeForTargettype (targetType) { PRODUCTTYPE_BY_TARGETTYPE = { application: 'com.apple.product-type.application', diff --git a/lib/pbxWriter.js b/lib/pbxWriter.js index 0fe289a..a6d918a 100644 --- a/lib/pbxWriter.js +++ b/lib/pbxWriter.js @@ -15,13 +15,10 @@ under the License. */ -var pbxProj = require('./pbxProject'); - var util = require('util'); var f = util.format; var INDENT = '\t'; var COMMENT_KEY = /_comment$/; -var QUOTED = /^"(.*)"$/; var EventEmitter = require('events').EventEmitter; // indentation diff --git a/test/BuildSettings.js b/test/BuildSettings.js index 759530e..4e02b6a 100644 --- a/test/BuildSettings.js +++ b/test/BuildSettings.js @@ -19,7 +19,6 @@ var fullProject = require('./fixtures/full-project'); var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); -var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); function cleanHash () { diff --git a/test/HeaderSearchPaths.js b/test/HeaderSearchPaths.js index 3fe7885..816498d 100644 --- a/test/HeaderSearchPaths.js +++ b/test/HeaderSearchPaths.js @@ -19,7 +19,6 @@ var fullProject = require('./fixtures/full-project'); var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); -var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); function cleanHash () { diff --git a/test/LibrarySearchPaths.js b/test/LibrarySearchPaths.js index 6f0aecb..b5d0d94 100644 --- a/test/LibrarySearchPaths.js +++ b/test/LibrarySearchPaths.js @@ -19,7 +19,6 @@ var fullProject = require('./fixtures/full-project'); var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); -var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); function cleanHash () { diff --git a/test/OtherLinkerFlags.js b/test/OtherLinkerFlags.js index b72e203..4fe6a1f 100644 --- a/test/OtherLinkerFlags.js +++ b/test/OtherLinkerFlags.js @@ -19,7 +19,6 @@ var fullProject = require('./fixtures/full-project'); var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); -var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); function cleanHash () { diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index 0ceb61b..340c985 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -21,27 +21,27 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash () { +function cleanHash() { return JSON.parse(fullProjectStr); } exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -}; +} exports.addBuildPhase = { 'should return a pbxBuildPhase': function (test) { var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); test.ok(typeof buildPhase === 'object'); - test.done(); + test.done() }, 'should set a uuid on the pbxBuildPhase': function (test) { var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); test.ok(buildPhase.uuid); - test.done(); + test.done() }, 'should add all files to build phase': function (test) { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; @@ -50,7 +50,7 @@ exports.addBuildPhase = { test.ok(file.value); } - test.done(); + test.done() }, 'should add the PBXBuildPhase object correctly': function (test) { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; @@ -77,7 +77,6 @@ exports.addBuildPhase = { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; var fileRefSection = proj.pbxFileReferenceSection(); var buildFileSection = proj.pbxBuildFileSection(); - var fileRefs = []; for (var index = 0; index < buildPhase.files.length; index++) { var file = buildPhase.files[index]; @@ -91,16 +90,16 @@ exports.addBuildPhase = { 'should not add files to PBXFileReference section if already added': function (test) { var fileRefSection = proj.pbxFileReferenceSection(); var initialFileReferenceSectionItemsCount = Object.keys(fileRefSection); - var buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; var afterAdditionBuildFileSectionItemsCount = Object.keys(fileRefSection); test.deepEqual(initialFileReferenceSectionItemsCount, afterAdditionBuildFileSectionItemsCount); test.done(); }, 'should not add files to PBXBuildFile section if already added': function (test) { - var buildFileSection = proj.pbxBuildFileSection(); - var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); - var buildPhase = proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + var buildFileSection = proj.pbxBuildFileSection(); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); @@ -188,11 +187,11 @@ exports.addBuildPhase = { test.equal(buildPhase.dstSubfolderSpec, 13); test.done(); }, - 'should add a script build phase to echo "hello world!"': function (test) { - var options = { shellPath: '/bin/sh', shellScript: 'echo "hello world!"' }; + 'should add a script build phase to echo "hello world!"': function(test) { + var options = {shellPath: '/bin/sh', shellScript: 'echo "hello world!"'}; var buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; test.equal(buildPhase.shellPath, '/bin/sh'); test.equal(buildPhase.shellScript, '"echo \\"hello world!\\""'); test.done(); - } -}; + }, +} diff --git a/test/addFramework.js b/test/addFramework.js index 5ef2350..2c32315 100644 --- a/test/addFramework.js +++ b/test/addFramework.js @@ -153,7 +153,7 @@ exports.addFramework = { }, 'should add to the Frameworks PBXGroup': function (test) { var newLength = proj.pbxGroupByName('Frameworks').children.length + 1; - var newFile = proj.addFramework('libsqlite3.dylib'); + proj.addFramework('libsqlite3.dylib'); var frameworks = proj.pbxGroupByName('Frameworks'); test.equal(frameworks.children.length, newLength); @@ -169,14 +169,14 @@ exports.addFramework = { test.done(); }, 'should add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'); + proj.addFramework('libsqlite3.dylib'); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); test.done(); }, 'should not add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('Private.framework', { link: false }); + proj.addFramework('Private.framework', { link: false }); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); @@ -193,7 +193,7 @@ exports.addFramework = { }, 'duplicate entries': { 'should return false': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'); + proj.addFramework('libsqlite3.dylib'); test.ok(!proj.addFramework('libsqlite3.dylib')); test.done(); @@ -223,7 +223,7 @@ exports.addFramework = { test.done(); }, 'should add to the Embed Frameworks PBXCopyFilesBuildPhase': function (test) { - var newFile = proj.addFramework('/path/to/SomeEmbeddableCustom.framework', { customFramework: true, embed: true }); + proj.addFramework('/path/to/SomeEmbeddableCustom.framework', { customFramework: true, embed: true }); var frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); var buildPhaseInPbx = proj.pbxEmbedFrameworksBuildPhaseObj(); @@ -233,7 +233,7 @@ exports.addFramework = { test.done(); }, 'should not add to the Embed Frameworks PBXCopyFilesBuildPhase by default': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true }); + proj.addFramework('/path/to/Custom.framework', { customFramework: true }); var frameworks = proj.pbxEmbedFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 0); diff --git a/test/addHeaderFile.js b/test/addHeaderFile.js index b1254bc..f17a706 100644 --- a/test/addHeaderFile.js +++ b/test/addHeaderFile.js @@ -78,7 +78,7 @@ exports.addHeaderFile = { test.done(); }, 'should add to the Plugins PBXGroup group': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'); + proj.addHeaderFile('Plugins/file.h'); var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); @@ -95,13 +95,13 @@ exports.addHeaderFile = { }, 'duplicate entries': { 'should return false': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'); + proj.addHeaderFile('Plugins/file.h'); test.ok(!proj.addHeaderFile('Plugins/file.h')); test.done(); }, 'should not add another entry anywhere': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'); + proj.addHeaderFile('Plugins/file.h'); var fileRefSection = proj.pbxFileReferenceSection(); var frsLength = Object.keys(fileRefSection).length; var plugins = proj.pbxGroupByName('Plugins'); diff --git a/test/addRemovePbxGroup.js b/test/addRemovePbxGroup.js index 65c278e..accaa34 100644 --- a/test/addRemovePbxGroup.js +++ b/test/addRemovePbxGroup.js @@ -63,7 +63,7 @@ exports.addRemovePbxGroup = { test.done(); }, 'should add sourceTree if no other specified': function (test) { - var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application'); + proj.addPbxGroup(['file.m'], 'MyGroup', 'Application'); pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); test.equal(pbxGroupInPbx.sourceTree, '""'); @@ -77,7 +77,7 @@ exports.addRemovePbxGroup = { } var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); - var pbxGroup = proj.addPbxGroup(['file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); // for each file added in the build file section two keyes are added - one for the object and one for the comment @@ -87,7 +87,7 @@ exports.addRemovePbxGroup = { 'should not add any of the files to PBXBuildFile section if already added': function (test) { var buildFileSection = proj.pbxBuildFileSection(); var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); - var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); @@ -96,7 +96,7 @@ exports.addRemovePbxGroup = { 'should not add any of the files to PBXBuildFile section when they contain special symbols and are already added': function (test) { var buildFileSection = proj.pbxBuildFileSection(); var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); - var pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); @@ -110,7 +110,7 @@ exports.addRemovePbxGroup = { } var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); - var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); // for each file added in the build file section two keyes are added - one for the object and one for the comment @@ -134,7 +134,7 @@ exports.addRemovePbxGroup = { 'should not add any of the files to PBXFileReference section if already added': function (test) { var fileReference = proj.pbxFileReferenceSection(); var initialBuildFileSectionItemsCount = Object.keys(fileReference); - var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); @@ -143,7 +143,7 @@ exports.addRemovePbxGroup = { 'should not add any of the files to PBXFileReference section when they contain special symbols and are already added': function (test) { var fileReference = proj.pbxFileReferenceSection(); var initialBuildFileSectionItemsCount = Object.keys(fileReference); - var pbxGroup = proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['KitchenSinktablet.app'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); @@ -157,7 +157,7 @@ exports.addRemovePbxGroup = { } var initialBuildFileSectionItemsCount = Object.keys(fileReference); - var pbxGroup = proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); + proj.addPbxGroup(['AppDelegate.m', 'AppDelegate.h', 'file.m', 'assets.bundle'], 'MyGroup', 'Application', '""'); var afterAdditionBuildFileSectionItemsCount = Object.keys(fileReference); // for each file added in the file reference section two keyes are added - one for the object and one for the comment diff --git a/test/addResourceFile.js b/test/addResourceFile.js index 6bc4298..fc1b522 100644 --- a/test/addResourceFile.js +++ b/test/addResourceFile.js @@ -116,7 +116,7 @@ exports.addResourceFile = { test.done(); }, 'should add to the Resources PBXGroup group': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'); + proj.addResourceFile('Resources/assets.bundle'); var resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 10); @@ -132,7 +132,7 @@ exports.addResourceFile = { test.done(); }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'); + proj.addResourceFile('Resources/assets.bundle'); var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 13); @@ -178,7 +178,7 @@ exports.addResourceFile = { }, 'should add to the Plugins PBXGroup group': function (test) { - var newFile = proj.addResourceFile('Plugins/assets.bundle', + proj.addResourceFile('Plugins/assets.bundle', { plugin: true }); var plugins = proj.pbxGroupByName('Plugins'); @@ -200,7 +200,7 @@ exports.addResourceFile = { }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addResourceFile('Plugins/assets.bundle', + proj.addResourceFile('Plugins/assets.bundle', { plugin: true }); var sources = proj.pbxResourcesBuildPhaseObj(); @@ -251,13 +251,13 @@ exports.addResourceFile = { }, 'duplicate entries': { 'should return false': function (test) { - var newFile = proj.addResourceFile('Plugins/assets.bundle'); + proj.addResourceFile('Plugins/assets.bundle'); test.ok(!proj.addResourceFile('Plugins/assets.bundle')); test.done(); }, 'should return false (plugin entries)': function (test) { - var newFile = proj.addResourceFile('Plugins/assets.bundle', + proj.addResourceFile('Plugins/assets.bundle', { plugin: true }); test.ok(!proj.addResourceFile('Plugins/assets.bundle', @@ -265,7 +265,7 @@ exports.addResourceFile = { test.done(); }, 'should not add another entry anywhere': function (test) { - var newFile = proj.addResourceFile('Plugins/assets.bundle'); + proj.addResourceFile('Plugins/assets.bundle'); var buildFileSection = proj.pbxBuildFileSection(); var bfsLength = Object.keys(buildFileSection).length; var fileRefSection = proj.pbxFileReferenceSection(); diff --git a/test/addSourceFile.js b/test/addSourceFile.js index 28f8b6f..cbd3a01 100644 --- a/test/addSourceFile.js +++ b/test/addSourceFile.js @@ -114,7 +114,7 @@ exports.addSourceFile = { test.done(); }, 'should add to the Plugins PBXGroup group': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'); + proj.addSourceFile('Plugins/file.m'); var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); @@ -130,7 +130,7 @@ exports.addSourceFile = { test.done(); }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'); + proj.addSourceFile('Plugins/file.m'); var sources = proj.pbxSourcesBuildPhaseObj(); test.equal(sources.files.length, 3); @@ -147,13 +147,13 @@ exports.addSourceFile = { }, 'duplicate entries': { 'should return false': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'); + proj.addSourceFile('Plugins/file.m'); test.ok(!proj.addSourceFile('Plugins/file.m')); test.done(); }, 'should not add another entry anywhere': function (test) { - var newFile = proj.addSourceFile('Plugins/file.m'); + proj.addSourceFile('Plugins/file.m'); var buildFileSection = proj.pbxBuildFileSection(); var bfsLength = Object.keys(buildFileSection).length; var fileRefSection = proj.pbxFileReferenceSection(); diff --git a/test/addStaticLibrary.js b/test/addStaticLibrary.js index d42446f..98f3e54 100644 --- a/test/addStaticLibrary.js +++ b/test/addStaticLibrary.js @@ -151,7 +151,7 @@ exports.addStaticLibrary = { test.done(); }, 'should add to the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + proj.addStaticLibrary('libGoogleAnalytics.a'); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); @@ -167,7 +167,7 @@ exports.addStaticLibrary = { test.done(); }, 'should set LIBRARY_SEARCH_PATHS for appropriate build configurations': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + proj.addStaticLibrary('libGoogleAnalytics.a'); var configs = nonComments(proj.pbxXCBuildConfigurationSection()); var ids = Object.keys(configs); var i; @@ -184,9 +184,8 @@ exports.addStaticLibrary = { test.done(); }, 'should ensure LIBRARY_SEARCH_PATHS inherits defaults correctly': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + proj.addStaticLibrary('libGoogleAnalytics.a'); var libraryPaths = librarySearchPaths(proj); - var expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""'; var i; var current; @@ -198,7 +197,7 @@ exports.addStaticLibrary = { test.done(); }, 'should ensure the new library is in LIBRARY_SEARCH_PATHS': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + proj.addStaticLibrary('libGoogleAnalytics.a'); var libraryPaths = librarySearchPaths(proj); var expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""'; var i; @@ -212,7 +211,7 @@ exports.addStaticLibrary = { test.done(); }, 'should add to the Plugins group, optionally': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a', + proj.addStaticLibrary('libGoogleAnalytics.a', { plugin: true }); var plugins = proj.pbxGroupByName('Plugins'); @@ -225,7 +224,7 @@ exports.addStaticLibrary = { plugins = proj.pbxGroupByName('Plugins'); plugins.path = '"Test200/Plugins"'; - var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', + proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', { plugin: true }); var libraryPaths = librarySearchPaths(proj); @@ -245,7 +244,7 @@ exports.addStaticLibrary = { plugins = proj.pbxGroupByName('Plugins'); delete plugins.path; - var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', + proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', { plugin: true }); var libraryPaths = librarySearchPaths(proj); @@ -264,13 +263,13 @@ exports.addStaticLibrary = { }, 'duplicate entries': { 'should return false': function (test) { - var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); + proj.addStaticLibrary('libGoogleAnalytics.a'); test.ok(!proj.addStaticLibrary('libGoogleAnalytics.a')); test.done(); }, 'should return false (plugin entries)': function (test) { - var newFile = proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', + proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', { plugin: true }); test.ok(!proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index 5660ddd..0d8c003 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -96,7 +96,7 @@ exports.dataModelDocument = { test.done(); }, 'should add to resources group by default': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath); + proj.addDataModelDocument(singleDataModelFilePath); groupChildren = proj.pbxGroupByName('Resources').children, found = false; @@ -111,7 +111,7 @@ exports.dataModelDocument = { }, 'should add to group specified by key': function (test) { var group = 'Frameworks'; - var newFile = proj.addDataModelDocument(singleDataModelFilePath, proj.findPBXGroupKey({ name: group })); + proj.addDataModelDocument(singleDataModelFilePath, proj.findPBXGroupKey({ name: group })); groupChildren = proj.pbxGroupByName(group).children; var found = false; @@ -126,7 +126,7 @@ exports.dataModelDocument = { }, 'should add to group specified by name': function (test) { var group = 'Frameworks'; - var newFile = proj.addDataModelDocument(singleDataModelFilePath, group); + proj.addDataModelDocument(singleDataModelFilePath, group); groupChildren = proj.pbxGroupByName(group).children; var found = false; @@ -140,7 +140,7 @@ exports.dataModelDocument = { test.done(); }, 'should add to the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath); + proj.addDataModelDocument(singleDataModelFilePath); var sources = proj.pbxSourcesBuildPhaseObj(); test.equal(sources.files.length, 2 + 1); diff --git a/test/group.js b/test/group.js index fda8b0f..4233700 100644 --- a/test/group.js +++ b/test/group.js @@ -19,7 +19,7 @@ var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var project; -var projectHash; +var projectHash; // eslint-disable-line var findChildInGroup = function (obj, target) { var found = false; @@ -417,7 +417,6 @@ exports.testWritingPBXProject = { } var target; - var projectTargets = pbxProject.targets; for (var i = 0, j = pbxProject.targets.length; i < j; i++) { target = pbxProject.targets[i].value; } @@ -438,7 +437,7 @@ exports.testWritingPBXProject = { } }; - var output = project.writeSync(); + project.writeSync(); test.done(); }, diff --git a/test/parser/build-config.js b/test/parser/build-config.js index 9c2b8da..6bc2d3e 100644 --- a/test/parser/build-config.js +++ b/test/parser/build-config.js @@ -22,7 +22,6 @@ var pbx = fs.readFileSync('test/parser/projects/build-config.pbxproj', 'utf-8'); var grammar = fs.readFileSync('lib/parser/pbxproj.pegjs', 'utf-8'); var parser = PEG.generate(grammar); var rawProj = parser.parse(pbx); -var util = require('util'); var project = rawProj.project; exports['should parse the build config section'] = function (test) { diff --git a/test/pbxProject.js b/test/pbxProject.js index e68d827..071d4e0 100644 --- a/test/pbxProject.js +++ b/test/pbxProject.js @@ -20,7 +20,6 @@ var pbx = require('../lib/pbxProject'); var buildConfig = require('./fixtures/buildFiles'); var jsonProject = require('./fixtures/full-project'); var fs = require('fs'); -var project; exports.creation = { 'should create a pbxProject with the new operator': function (test) { diff --git a/test/pbxWriter.js b/test/pbxWriter.js index 7da615c..b79c4e4 100644 --- a/test/pbxWriter.js +++ b/test/pbxWriter.js @@ -18,7 +18,6 @@ var pbx = require('../lib/pbxProject'); var fs = require('fs'); -var myProj; function testProjectContents (filename, test, expectedFilename) { var myProj = new pbx(filename); @@ -35,30 +34,21 @@ function testProjectContents (filename, test, expectedFilename) { myProj.parse(function (err, projHash) { var written = myProj.writeSync(); - test.equal(content, written); - test.done(); - }); -} - -// for debugging failing tests -function testContentsInDepth (filename, test) { - var myProj = new pbx(filename); - var content = fs.readFileSync(filename, 'utf-8'); + // for debugging failing tests start + // var writtenLines = written.split('\n'); + // contentLines = content.split('\n'); - // normalize tabs vs strings - content = content.replace(/ {4}/g, '\t'); - - myProj.parse(function (err, projHash) { - var written = myProj.writeSync(); - var writtenLines = written.split('\n'); - contentLines = content.split('\n'); + // test.equal(writtenLines.length, contentLines.length); - test.equal(writtenLines.length, contentLines.length); + // for (var i = 0; i < writtenLines.length; i++) { + // test.equal(writtenLines[i], contentLines[i], + // 'match failed on line ' + (i + 1)); + // } + // for debugging failing tests end - for (var i = 0; i < writtenLines.length; i++) { - test.equal(writtenLines[i], contentLines[i], - 'match failed on line ' + (i + 1)); - } + // for normal tests start + test.equal(content, written); + // for normal tests end test.done(); }); diff --git a/test/removeFramework.js b/test/removeFramework.js index 8252532..42bf66d 100644 --- a/test/removeFramework.js +++ b/test/removeFramework.js @@ -125,12 +125,12 @@ exports.removeFramework = { }, 'should remove from the Frameworks PBXGroup': function (test) { var newLength = proj.pbxGroupByName('Frameworks').children.length + 1; - var newFile = proj.addFramework('libsqlite3.dylib'); + proj.addFramework('libsqlite3.dylib'); var frameworks = proj.pbxGroupByName('Frameworks'); test.equal(frameworks.children.length, newLength); - var deletedFile = proj.removeFramework('libsqlite3.dylib'); + proj.removeFramework('libsqlite3.dylib'); var newLength = newLength - 1; test.equal(frameworks.children.length, newLength); @@ -138,12 +138,12 @@ exports.removeFramework = { test.done(); }, 'should remove from the PBXFrameworksBuildPhase': function (test) { - var newFile = proj.addFramework('libsqlite3.dylib'); + proj.addFramework('libsqlite3.dylib'); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); - var deletedFile = proj.removeFramework('libsqlite3.dylib'); + proj.removeFramework('libsqlite3.dylib'); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); @@ -151,12 +151,12 @@ exports.removeFramework = { test.done(); }, 'should remove custom frameworks': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true }); + proj.addFramework('/path/to/Custom.framework', { customFramework: true }); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 16); - var deletedFile = proj.removeFramework('/path/to/Custom.framework', { customFramework: true }); + proj.removeFramework('/path/to/Custom.framework', { customFramework: true }); var frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); @@ -172,7 +172,7 @@ exports.removeFramework = { test.done(); }, 'should remove embedded frameworks': function (test) { - var newFile = proj.addFramework('/path/to/Custom.framework', { customFramework: true, embed: true, sign: true }); + proj.addFramework('/path/to/Custom.framework', { customFramework: true, embed: true, sign: true }); var frameworks = proj.pbxFrameworksBuildPhaseObj(); var buildFileSection = proj.pbxBuildFileSection(); var bfsLength = Object.keys(buildFileSection).length; @@ -180,7 +180,7 @@ exports.removeFramework = { test.equal(frameworks.files.length, 16); test.equal(62, bfsLength); - var deletedFile = proj.removeFramework('/path/to/Custom.framework', { customFramework: true, embed: true }); + proj.removeFramework('/path/to/Custom.framework', { customFramework: true, embed: true }); var frameworks = proj.pbxFrameworksBuildPhaseObj(); var buildFileSection = proj.pbxBuildFileSection(); var bfsLength = Object.keys(buildFileSection).length; diff --git a/test/removeHeaderFile.js b/test/removeHeaderFile.js index e2965a5..7e9550e 100644 --- a/test/removeHeaderFile.js +++ b/test/removeHeaderFile.js @@ -108,12 +108,12 @@ exports.removeHeaderFile = { test.done(); }, 'should remove from the Plugins PBXGroup group': function (test) { - var newFile = proj.addHeaderFile('Plugins/file.h'); + proj.addHeaderFile('Plugins/file.h'); var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 1); - var deletedFile = proj.removeHeaderFile('Plugins/file.h'); + proj.removeHeaderFile('Plugins/file.h'); var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 0); diff --git a/test/removeResourceFile.js b/test/removeResourceFile.js index b9ded76..19548e4 100644 --- a/test/removeResourceFile.js +++ b/test/removeResourceFile.js @@ -172,24 +172,24 @@ exports.removeResourceFile = { test.done(); }, 'should remove from the Resources PBXGroup group': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'); + proj.addResourceFile('Resources/assets.bundle'); var resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 10); - var deletedFile = proj.removeResourceFile('Resources/assets.bundle'); + proj.removeResourceFile('Resources/assets.bundle'); var resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 9); test.done(); }, 'should remove from the PBXSourcesBuildPhase': function (test) { - var newFile = proj.addResourceFile('Resources/assets.bundle'); + proj.addResourceFile('Resources/assets.bundle'); var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 13); - var deletedFile = proj.removeResourceFile('Resources/assets.bundle'); + proj.removeResourceFile('Resources/assets.bundle'); var sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 12); diff --git a/test/removeSourceFile.js b/test/removeSourceFile.js index 67cd9c8..6806fd6 100644 --- a/test/removeSourceFile.js +++ b/test/removeSourceFile.js @@ -114,14 +114,14 @@ exports.removeSourceFile = { }, 'should remove from the Plugins PBXGroup group': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'); + proj.removeSourceFile('Plugins/file.m'); var plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 0); test.done(); }, 'should have the right values for the PBXGroup entry': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'); + proj.removeSourceFile('Plugins/file.m'); var plugins = proj.pbxGroupByName('Plugins'); var pluginObj = plugins.children[0]; @@ -130,7 +130,7 @@ exports.removeSourceFile = { }, 'should remove from the PBXSourcesBuildPhase': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'); + proj.removeSourceFile('Plugins/file.m'); var sources = proj.pbxSourcesBuildPhaseObj(); test.equal(sources.files.length, 2); @@ -138,7 +138,7 @@ exports.removeSourceFile = { }, 'should have the right values for the Sources entry': function (test) { proj.addSourceFile('Plugins/file.m'); - var newFile = proj.removeSourceFile('Plugins/file.m'); + proj.removeSourceFile('Plugins/file.m'); var sources = proj.pbxSourcesBuildPhaseObj(); var sourceObj = sources.files[2]; diff --git a/test/variantGroup.js b/test/variantGroup.js index 5c67a63..2481e1e 100644 --- a/test/variantGroup.js +++ b/test/variantGroup.js @@ -18,7 +18,7 @@ var pbx = require('../lib/pbxProject'); var project; -var projectHash; +var projectHash; // eslint-disable-line var findChildInGroup = function (obj, target) { var found = false; @@ -33,33 +33,6 @@ var findChildInGroup = function (obj, target) { return found; }; -var findFileByUUID = function (obj, target) { - var found = false; - - for (var k = 0, l = obj.files.length; k < l; k++) { - if (obj.files[k].value === target) { - found = true; - break; - } - } - - return found; -}; - -var findByFileRef = function (obj, target) { - var found = false; - - for (var property in obj) { - if (!/comment/.test(property)) { - if (obj[property].fileRef === target) { - found = true; - break; - } - } - } - return found; -}; - var findByName = function (obj, target) { var found = false; for (var property in obj) { diff --git a/test/xcode5searchPaths.js b/test/xcode5searchPaths.js index 7f5abb3..08c9ceb 100644 --- a/test/xcode5searchPaths.js +++ b/test/xcode5searchPaths.js @@ -19,7 +19,6 @@ var xcode5proj = require('./fixtures/library-search-paths'); var xcode5projStr = JSON.stringify(xcode5proj); var pbx = require('../lib/pbxProject'); -var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); var libPoop = { path: 'some/path/poop.a' }; From 91b7311248dd60264f380d7f148d65a126710806 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:11:46 +0900 Subject: [PATCH 07/22] chore: fix eslint no-redeclare problems --- lib/pbxFile.js | 2 +- lib/pbxProject.js | 16 ++++++++-------- test/FrameworkSearchPaths.js | 1 - test/group.js | 24 ++++++++++++------------ test/multipleTargets.js | 6 +++--- test/removeFramework.js | 12 ++++++------ test/removeHeaderFile.js | 14 +++++++------- test/removeResourceFile.js | 28 ++++++++++++++-------------- test/variantGroup.js | 4 ++-- 9 files changed, 53 insertions(+), 54 deletions(-) diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 17a2811..28bcd1c 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -174,7 +174,7 @@ function defaultPath (fileRef, filePath) { } function pbxFile (filepath, opt) { - var opt = opt || {}; + opt = opt || {}; this.basename = path.basename(filepath); this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath); diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 0fb79eb..e8af561 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -825,8 +825,8 @@ pbxProject.prototype.addTargetDependency = function (target, dependencyTargets) var pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency]; var pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; - for (var index = 0; index < dependencyTargets.length; index++) { - var dependencyTargetUuid = dependencyTargets[index]; + for (var index2 = 0; index2 < dependencyTargets.length; index2++) { + var dependencyTargetUuid = dependencyTargets[index2]; var dependencyTargetCommentKey = f('%s_comment', dependencyTargetUuid); var targetDependencyUuid = this.generateUuid(); var targetDependencyCommentKey = f('%s_comment', targetDependencyUuid); @@ -1479,13 +1479,13 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { ); } else if (targetType === 'watch2_extension') { // Create CopyFiles phase in watch target (if exists) - var watch2Target = this.getTarget(producttypeForTargettype('watch2_app')); - if (watch2Target) { + var watch2AppTarget = this.getTarget(producttypeForTargettype('watch2_app')); + if (watch2AppTarget) { this.addBuildPhase( [targetName + '.appex'], 'PBXCopyFilesBuildPhase', 'Embed App Extensions', - watch2Target.uuid, + watch2AppTarget.uuid, targetType ); } @@ -1496,9 +1496,9 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { // Target: Add dependency for this target to other targets if (targetType === 'watch2_extension') { - var watch2Target = this.getTarget(producttypeForTargettype('watch2_app')); - if (watch2Target) { - this.addTargetDependency(watch2Target.uuid, [target.uuid]); + var watch2ExtensionTarget = this.getTarget(producttypeForTargettype('watch2_app')); + if (watch2ExtensionTarget) { + this.addTargetDependency(watch2ExtensionTarget.uuid, [target.uuid]); } } else { this.addTargetDependency(this.getFirstTarget().uuid, [target.uuid]); diff --git a/test/FrameworkSearchPaths.js b/test/FrameworkSearchPaths.js index b9c4b26..142a4d6 100644 --- a/test/FrameworkSearchPaths.js +++ b/test/FrameworkSearchPaths.js @@ -19,7 +19,6 @@ var fullProject = require('./fixtures/full-project'); var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); -var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); var pbxFile = { diff --git a/test/group.js b/test/group.js index 4233700..bd3238f 100644 --- a/test/group.js +++ b/test/group.js @@ -100,7 +100,7 @@ exports.createGroup = { var found = false; var groups = project.getPBXObject('PBXGroup'); - var found = findByName(groups, 'Test'); + found = findByName(groups, 'Test'); test.ok(found === false); var group = project.findPBXGroupKey({ name: 'Test' }); @@ -268,13 +268,13 @@ exports.removeSourceFileFromGroup = { project.removeSourceFile('Notifications.m', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); + foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); - var foundInBuildFileSection = findByFileRef(project.pbxBuildFileSection(), file.fileRef); + foundInBuildFileSection = findByFileRef(project.pbxBuildFileSection(), file.fileRef); test.ok(!foundInBuildFileSection); - var foundInBuildPhase = findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid); + foundInBuildPhase = findFileByUUID(project.pbxSourcesBuildPhaseObj(), file.uuid); test.ok(!foundInBuildPhase); test.done(); @@ -303,7 +303,7 @@ exports.removeHeaderFileFromGroup = { project.removeHeaderFile('Notifications.h', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); + foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); test.done(); @@ -332,7 +332,7 @@ exports.removeResourceFileFromGroup = { project.removeResourceFile('DefaultTest-667h.png', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); + foundInGroup = findChildInGroup(project.getPBXGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); test.done(); @@ -358,15 +358,15 @@ exports.retrieveBuildPropertyForBuild = { exports.retrieveBuildConfigByName = { 'should retrieve valid build config': function (test) { var releaseBuildConfig = project.getBuildConfigByName('Release'); - for (var property in releaseBuildConfig) { - var value = releaseBuildConfig[property]; - test.ok(value.name === 'Release'); + for (var releaseProperty in releaseBuildConfig) { + var releaseValue = releaseBuildConfig[releaseProperty]; + test.ok(releaseValue.name === 'Release'); } var debugBuildConfig = project.getBuildConfigByName('Debug'); - for (var property in debugBuildConfig) { - var value = debugBuildConfig[property]; - test.ok(value.name === 'Debug'); + for (var debugProperty in debugBuildConfig) { + var debugValue = debugBuildConfig[debugProperty]; + test.ok(debugValue.name === 'Debug'); } var nonExistingBuildConfig = project.getBuildConfigByName('Foo'); diff --git a/test/multipleTargets.js b/test/multipleTargets.js index 3404da0..f08c692 100644 --- a/test/multipleTargets.js +++ b/test/multipleTargets.js @@ -60,7 +60,7 @@ exports.addFilesToTarget = { var l = sources.files.length; proj.removeSourceFile(filename, opt); - var sources = proj.pbxSourcesBuildPhaseObj(target); + sources = proj.pbxSourcesBuildPhaseObj(target); test.equal(sources.files.length, l - 1); test.done(); @@ -104,7 +104,7 @@ exports.addFilesToTarget = { var l = libraries.files.length; proj.removeFramework(filename, opt); - var libraries = proj.pbxFrameworksBuildPhaseObj(target); + libraries = proj.pbxFrameworksBuildPhaseObj(target); test.equal(libraries.files.length, l - 1); test.done(); @@ -152,7 +152,7 @@ exports.addFilesToTarget = { var l = resources.files.length; proj.removeResourceFile(filename, opt); - var resources = proj.pbxResourcesBuildPhaseObj(target); + resources = proj.pbxResourcesBuildPhaseObj(target); test.equal(resources.files.length, l - 1); test.done(); diff --git a/test/removeFramework.js b/test/removeFramework.js index 42bf66d..370ecf2 100644 --- a/test/removeFramework.js +++ b/test/removeFramework.js @@ -131,7 +131,7 @@ exports.removeFramework = { test.equal(frameworks.children.length, newLength); proj.removeFramework('libsqlite3.dylib'); - var newLength = newLength - 1; + newLength = newLength - 1; test.equal(frameworks.children.length, newLength); @@ -144,7 +144,7 @@ exports.removeFramework = { test.equal(frameworks.files.length, 16); proj.removeFramework('libsqlite3.dylib'); - var frameworks = proj.pbxFrameworksBuildPhaseObj(); + frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); @@ -157,7 +157,7 @@ exports.removeFramework = { test.equal(frameworks.files.length, 16); proj.removeFramework('/path/to/Custom.framework', { customFramework: true }); - var frameworks = proj.pbxFrameworksBuildPhaseObj(); + frameworks = proj.pbxFrameworksBuildPhaseObj(); test.equal(frameworks.files.length, 15); @@ -181,9 +181,9 @@ exports.removeFramework = { test.equal(62, bfsLength); proj.removeFramework('/path/to/Custom.framework', { customFramework: true, embed: true }); - var frameworks = proj.pbxFrameworksBuildPhaseObj(); - var buildFileSection = proj.pbxBuildFileSection(); - var bfsLength = Object.keys(buildFileSection).length; + frameworks = proj.pbxFrameworksBuildPhaseObj(); + buildFileSection = proj.pbxBuildFileSection(); + bfsLength = Object.keys(buildFileSection).length; test.equal(frameworks.files.length, 15); test.equal(58, bfsLength); diff --git a/test/removeHeaderFile.js b/test/removeHeaderFile.js index 7e9550e..3dd4fb7 100644 --- a/test/removeHeaderFile.js +++ b/test/removeHeaderFile.js @@ -64,8 +64,8 @@ exports.removeHeaderFile = { test.ok(fileRefSection[newFile.fileRef + '_comment']); var deletedFile = proj.removeHeaderFile('file.h'); - var fileRefSection = proj.pbxFileReferenceSection(); - var frsLength = Object.keys(fileRefSection).length; + fileRefSection = proj.pbxFileReferenceSection(); + frsLength = Object.keys(fileRefSection).length; test.equal(66, frsLength); test.ok(!fileRefSection[deletedFile.fileRef]); @@ -81,8 +81,8 @@ exports.removeHeaderFile = { test.equal(fileRefSection[commentKey], 'file.h'); var deletedFile = proj.removeHeaderFile('file.h'); - var fileRefSection = proj.pbxFileReferenceSection(); - var commentKey = deletedFile.fileRef + '_comment'; + fileRefSection = proj.pbxFileReferenceSection(); + commentKey = deletedFile.fileRef + '_comment'; test.ok(!fileRefSection[commentKey]); test.done(); @@ -100,8 +100,8 @@ exports.removeHeaderFile = { test.equal(fileRefEntry.sourceTree, '""'); var deletedFile = proj.removeHeaderFile('Plugins/file.h'); - var fileRefSection = proj.pbxFileReferenceSection(); - var fileRefEntry = fileRefSection[deletedFile.fileRef]; + fileRefSection = proj.pbxFileReferenceSection(); + fileRefEntry = fileRefSection[deletedFile.fileRef]; test.ok(!fileRefEntry); @@ -114,7 +114,7 @@ exports.removeHeaderFile = { test.equal(plugins.children.length, 1); proj.removeHeaderFile('Plugins/file.h'); - var plugins = proj.pbxGroupByName('Plugins'); + plugins = proj.pbxGroupByName('Plugins'); test.equal(plugins.children.length, 0); diff --git a/test/removeResourceFile.js b/test/removeResourceFile.js index 19548e4..551ba71 100644 --- a/test/removeResourceFile.js +++ b/test/removeResourceFile.js @@ -75,8 +75,8 @@ exports.removeResourceFile = { test.ok(buildFileSection[newFile.uuid + '_comment']); var deletedFile = proj.removeResourceFile('assets.bundle'); - var buildFileSection = proj.pbxBuildFileSection(); - var bfsLength = Object.keys(buildFileSection).length; + buildFileSection = proj.pbxBuildFileSection(); + bfsLength = Object.keys(buildFileSection).length; test.equal(58, bfsLength); test.ok(!buildFileSection[deletedFile.uuid]); @@ -92,8 +92,8 @@ exports.removeResourceFile = { test.equal(buildFileSection[commentKey], 'assets.bundle in Resources'); var deletedFile = proj.removeResourceFile('assets.bundle'); - var commentKey = deletedFile.uuid + '_comment'; - var buildFileSection = proj.pbxBuildFileSection(); + commentKey = deletedFile.uuid + '_comment'; + buildFileSection = proj.pbxBuildFileSection(); test.ok(!buildFileSection[commentKey]); @@ -109,8 +109,8 @@ exports.removeResourceFile = { test.equal(buildFileEntry.fileRef_comment, 'assets.bundle'); var deletedFile = proj.removeResourceFile('assets.bundle'); - var buildFileSection = proj.pbxBuildFileSection(); - var buildFileEntry = buildFileSection[deletedFile.uuid]; + buildFileSection = proj.pbxBuildFileSection(); + buildFileEntry = buildFileSection[deletedFile.uuid]; test.ok(!buildFileEntry); @@ -126,8 +126,8 @@ exports.removeResourceFile = { test.ok(fileRefSection[newFile.fileRef + '_comment']); var deletedFile = proj.removeResourceFile('assets.bundle'); - var fileRefSection = proj.pbxFileReferenceSection(); - var frsLength = Object.keys(fileRefSection).length; + fileRefSection = proj.pbxFileReferenceSection(); + frsLength = Object.keys(fileRefSection).length; test.equal(66, frsLength); test.ok(!fileRefSection[deletedFile.fileRef]); @@ -143,8 +143,8 @@ exports.removeResourceFile = { test.equal(fileRefSection[commentKey], 'assets.bundle'); var deletedFile = proj.removeResourceFile('assets.bundle'); - var fileRefSection = proj.pbxFileReferenceSection(); - var commentKey = deletedFile.fileRef + '_comment'; + fileRefSection = proj.pbxFileReferenceSection(); + commentKey = deletedFile.fileRef + '_comment'; test.ok(!fileRefSection[commentKey]); test.done(); @@ -164,8 +164,8 @@ exports.removeResourceFile = { test.equal(fileRefEntry.sourceTree, '""'); var deletedFile = proj.removeResourceFile('Resources/assets.bundle'); - var fileRefSection = proj.pbxFileReferenceSection(); - var fileRefEntry = fileRefSection[deletedFile.fileRef]; + fileRefSection = proj.pbxFileReferenceSection(); + fileRefEntry = fileRefSection[deletedFile.fileRef]; test.ok(!fileRefEntry); @@ -178,7 +178,7 @@ exports.removeResourceFile = { test.equal(resources.children.length, 10); proj.removeResourceFile('Resources/assets.bundle'); - var resources = proj.pbxGroupByName('Resources'); + resources = proj.pbxGroupByName('Resources'); test.equal(resources.children.length, 9); test.done(); @@ -190,7 +190,7 @@ exports.removeResourceFile = { test.equal(sources.files.length, 13); proj.removeResourceFile('Resources/assets.bundle'); - var sources = proj.pbxResourcesBuildPhaseObj(); + sources = proj.pbxResourcesBuildPhaseObj(); test.equal(sources.files.length, 12); test.done(); diff --git a/test/variantGroup.js b/test/variantGroup.js index 2481e1e..bbea147 100644 --- a/test/variantGroup.js +++ b/test/variantGroup.js @@ -68,7 +68,7 @@ exports.createVariantGroup = { var found = false; var groups = project.getPBXObject('PBXVariantGroup'); - var found = findByName(groups, 'Test'); + found = findByName(groups, 'Test'); test.ok(found === false); var group = project.findPBXVariantGroupKey({ name: 'Test' }); @@ -159,7 +159,7 @@ exports.removeResourceFileFromGroup = { project.removeResourceFile('Resources/zh.lproj/Localization.strings', {}, testKey); - var foundInGroup = findChildInGroup(project.getPBXVariantGroupByKey(testKey), file.fileRef); + foundInGroup = findChildInGroup(project.getPBXVariantGroupByKey(testKey), file.fileRef); test.ok(!foundInGroup); test.done(); From 283e47902dbda92937f7f4893efb480143b904c1 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:27:22 +0900 Subject: [PATCH 08/22] chore: fix eslint no-undef problems --- lib/pbxProject.js | 42 ++++++++++++++-------------------- test/addFramework.js | 12 +++++----- test/addRemovePbxGroup.js | 4 ++-- test/addStaticLibrary.js | 28 +++++++++++------------ test/addTarget.js | 4 ++-- test/addWatch2App.js | 4 ++-- test/addWatch2Extension.js | 4 ++-- test/addWatchApp.js | 4 ++-- test/addWatchExtension.js | 4 ++-- test/addXCConfigurationList.js | 16 ++++++------- test/dataModelDocument.js | 8 +++---- test/removeFramework.js | 18 +++++++-------- 12 files changed, 69 insertions(+), 79 deletions(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index e8af561..d83cb11 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -74,7 +74,7 @@ pbxProject.prototype.allUuids = function () { var uuids = []; var section; - for (key in sections) { + for (var key in sections) { section = sections[key]; uuids = uuids.concat(Object.keys(section)); } @@ -421,7 +421,7 @@ pbxProject.prototype.removeCopyfile = function (fpath, opt) { pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function (file) { var sources = this.pbxCopyfilesBuildPhaseObj(file.target); - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -572,9 +572,8 @@ pbxProject.prototype.addToPbxFileReferenceSection = function (file) { }; pbxProject.prototype.removeFromPbxFileReferenceSection = function (file) { - var i; var refObj = pbxFileReferenceObj(file); - for (i in this.pbxFileReferenceSection()) { + for (var i in this.pbxFileReferenceSection()) { if (this.pbxFileReferenceSection()[i].name === refObj.name || ('"' + this.pbxFileReferenceSection()[i].name + '"') === refObj.name || this.pbxFileReferenceSection()[i].path === refObj.path || @@ -627,8 +626,7 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function (file) { return null; } var pluginsGroupChildren = this.pbxGroupByName('Plugins').children; - var i; - for (i in pluginsGroupChildren) { + for (var i in pluginsGroupChildren) { if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -651,8 +649,7 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function (file) { return null; } var pluginsGroupChildren = this.pbxGroupByName('Resources').children; - var i; - for (i in pluginsGroupChildren) { + for (var i in pluginsGroupChildren) { if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -676,7 +673,7 @@ pbxProject.prototype.removeFromFrameworksPbxGroup = function (file) { } var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; - for (i in pluginsGroupChildren) { + for (var i in pluginsGroupChildren) { if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -696,7 +693,7 @@ pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); if (sources) { var files = []; - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment !== longComment(file)) { files.push(sources.files[i]); } @@ -719,8 +716,7 @@ pbxProject.prototype.removeFromProductsPbxGroup = function (file) { return null; } var productsGroupChildren = this.pbxGroupByName('Products').children; - var i; - for (i in productsGroupChildren) { + for (var i in productsGroupChildren) { if (pbxGroupChild(file).value === productsGroupChildren[i].value && pbxGroupChild(file).comment === productsGroupChildren[i].comment) { productsGroupChildren.splice(i, 1); @@ -736,8 +732,7 @@ pbxProject.prototype.addToPbxSourcesBuildPhase = function (file) { pbxProject.prototype.removeFromPbxSourcesBuildPhase = function (file) { var sources = this.pbxSourcesBuildPhaseObj(file.target); - var i; - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -752,9 +747,8 @@ pbxProject.prototype.addToPbxResourcesBuildPhase = function (file) { pbxProject.prototype.removeFromPbxResourcesBuildPhase = function (file) { var sources = this.pbxResourcesBuildPhaseObj(file.target); - var i; - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -769,7 +763,7 @@ pbxProject.prototype.addToPbxFrameworksBuildPhase = function (file) { pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function (file) { var sources = this.pbxFrameworksBuildPhaseObj(file.target); - for (i in sources.files) { + for (var i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -907,7 +901,7 @@ pbxProject.prototype.addBuildPhase = function (filePathsArray, buildPhaseType, c var buildFileKey = key.split(COMMENT_KEY)[0]; var buildFile = buildFileSection[buildFileKey]; - fileReference = fileReferenceSection[buildFile.fileRef]; + var fileReference = fileReferenceSection[buildFile.fileRef]; if (!fileReference) continue; @@ -1368,7 +1362,7 @@ pbxProject.prototype.hasFile = function (filePath) { var files = nonComments(this.pbxFileReferenceSection()); var file; var id; - for (id in files) { + for (var id in files) { file = files[id]; if (file.path === filePath || file.path === ('"' + filePath + '"')) { return file; @@ -1657,9 +1651,8 @@ function searchPathForFile (file, proj) { function nonComments (obj) { var keys = Object.keys(obj); var newObj = {}; - var i = 0; - for (i; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { if (!COMMENT_KEY.test(keys[i])) { newObj[keys[i]] = obj[keys[i]]; } @@ -1673,7 +1666,7 @@ function unquote (str) { } function producttypeForTargettype (targetType) { - PRODUCTTYPE_BY_TARGETTYPE = { + var PRODUCTTYPE_BY_TARGETTYPE = { application: 'com.apple.product-type.application', app_extension: 'com.apple.product-type.app-extension', bundle: 'com.apple.product-type.bundle', @@ -1692,7 +1685,7 @@ function producttypeForTargettype (targetType) { } function filetypeForProducttype (productType) { - FILETYPE_BY_PRODUCTTYPE = { + var FILETYPE_BY_PRODUCTTYPE = { 'com.apple.product-type.application': '"wrapper.application"', 'com.apple.product-type.app-extension': '"wrapper.app-extension"', 'com.apple.product-type.bundle': '"wrapper.plug-in"', @@ -1828,8 +1821,7 @@ pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, group var group = this.getPBXGroupByKeyAndType(groupKey, groupType); if (group) { var groupChildren = group.children; - var i; - for (i in groupChildren) { + for (var i in groupChildren) { if (pbxGroupChild(file).value === groupChildren[i].value && pbxGroupChild(file).comment === groupChildren[i].comment) { groupChildren.splice(i, 1); diff --git a/test/addFramework.js b/test/addFramework.js index 2c32315..30e871e 100644 --- a/test/addFramework.js +++ b/test/addFramework.js @@ -78,8 +78,8 @@ exports.addFramework = { }, 'should populate the PBXFileReference section with 2 fields': function (test) { var newFile = proj.addFramework('libsqlite3.dylib'); - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -89,8 +89,8 @@ exports.addFramework = { }, 'should populate the PBXFileReference comment correctly': function (test) { var newFile = proj.addFramework('libsqlite3.dylib'); - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'libsqlite3.dylib'); test.done(); @@ -213,9 +213,9 @@ exports.addFramework = { // should add path to framework search path var frameworkPaths = frameworkSearchPaths(proj); - expectedPath = '"\\"/path/to\\""'; + var expectedPath = '"\\"/path/to\\""'; - for (i = 0; i < frameworkPaths.length; i++) { + for (var i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; test.ok(current.indexOf('"$(inherited)"') >= 0); test.ok(current.indexOf(expectedPath) >= 0); diff --git a/test/addRemovePbxGroup.js b/test/addRemovePbxGroup.js index accaa34..938f4fa 100644 --- a/test/addRemovePbxGroup.js +++ b/test/addRemovePbxGroup.js @@ -54,7 +54,7 @@ exports.addRemovePbxGroup = { }, 'should add the PBXGroup object correctly': function (test) { var pbxGroup = proj.addPbxGroup(['file.m'], 'MyGroup', 'Application', '""'); - pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); + var pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); test.equal(pbxGroupInPbx.children, pbxGroup.pbxGroup.children); test.equal(pbxGroupInPbx.isa, 'PBXGroup'); @@ -64,7 +64,7 @@ exports.addRemovePbxGroup = { }, 'should add sourceTree if no other specified': function (test) { proj.addPbxGroup(['file.m'], 'MyGroup', 'Application'); - pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); + var pbxGroupInPbx = proj.pbxGroupByName('MyGroup'); test.equal(pbxGroupInPbx.sourceTree, '""'); test.done(); diff --git a/test/addStaticLibrary.js b/test/addStaticLibrary.js index 98f3e54..ecda8df 100644 --- a/test/addStaticLibrary.js +++ b/test/addStaticLibrary.js @@ -78,8 +78,8 @@ exports.addStaticLibrary = { }, 'should populate the PBXBuildFile section with 2 fields': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -90,8 +90,8 @@ exports.addStaticLibrary = { 'should populate the PBXBuildFile section with 2 fields as plugin': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a', { plugin: true }); - buildFileSection = proj.pbxBuildFileSection(), - bfsLength = Object.keys(buildFileSection).length; + var buildFileSection = proj.pbxBuildFileSection(); + var bfsLength = Object.keys(buildFileSection).length; test.equal(60, bfsLength); test.ok(buildFileSection[newFile.uuid]); @@ -101,16 +101,16 @@ exports.addStaticLibrary = { }, 'should add the PBXBuildFile comment correctly': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - commentKey = newFile.uuid + '_comment', - buildFileSection = proj.pbxBuildFileSection(); + var commentKey = newFile.uuid + '_comment'; + var buildFileSection = proj.pbxBuildFileSection(); test.equal(buildFileSection[commentKey], 'libGoogleAnalytics.a in Frameworks'); test.done(); }, 'should add the PBXBuildFile object correctly': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - buildFileSection = proj.pbxBuildFileSection(), - buildFileEntry = buildFileSection[newFile.uuid]; + var buildFileSection = proj.pbxBuildFileSection(); + var buildFileEntry = buildFileSection[newFile.uuid]; test.equal(buildFileEntry.isa, 'PBXBuildFile'); test.equal(buildFileEntry.fileRef, newFile.fileRef); @@ -120,8 +120,8 @@ exports.addStaticLibrary = { }, 'should populate the PBXFileReference section with 2 fields': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -131,8 +131,8 @@ exports.addStaticLibrary = { }, 'should populate the PBXFileReference comment correctly': function (test) { var newFile = proj.addStaticLibrary('libGoogleAnalytics.a'); - fileRefSection = proj.pbxFileReferenceSection(), - commentKey = newFile.fileRef + '_comment'; + var fileRefSection = proj.pbxFileReferenceSection(); + var commentKey = newFile.fileRef + '_comment'; test.equal(fileRefSection[commentKey], 'libGoogleAnalytics.a'); test.done(); @@ -221,7 +221,7 @@ exports.addStaticLibrary = { }, 'should add the right LIBRARY_SEARCH_PATHS entry for plugins': { 'with group set': function (test) { - plugins = proj.pbxGroupByName('Plugins'); + var plugins = proj.pbxGroupByName('Plugins'); plugins.path = '"Test200/Plugins"'; proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', @@ -241,7 +241,7 @@ exports.addStaticLibrary = { test.done(); }, 'without group set': function (test) { - plugins = proj.pbxGroupByName('Plugins'); + var plugins = proj.pbxGroupByName('Plugins'); delete plugins.path; proj.addStaticLibrary('Plugins/libGoogleAnalytics.a', diff --git a/test/addTarget.js b/test/addTarget.js index 65d22b6..78398ca 100644 --- a/test/addTarget.js +++ b/test/addTarget.js @@ -156,8 +156,8 @@ exports.addTarget = { var resourceFile = proj.addResourceFile('assets.bundle', options); var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); var frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid); + var headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatch2App.js b/test/addWatch2App.js index b9017a8..8abd45e 100644 --- a/test/addWatch2App.js +++ b/test/addWatch2App.js @@ -84,8 +84,8 @@ exports.addWatchApp = { var resourceFile = proj.addResourceFile('assets.bundle', options); var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); var frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid); + var headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatch2Extension.js b/test/addWatch2Extension.js index f2fda63..ca383c3 100644 --- a/test/addWatch2Extension.js +++ b/test/addWatch2Extension.js @@ -63,8 +63,8 @@ exports.addWatchExtension = { var resourceFile = proj.addResourceFile('assets.bundle', options); var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); var frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid); + var headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatchApp.js b/test/addWatchApp.js index 3763b64..853f1b3 100644 --- a/test/addWatchApp.js +++ b/test/addWatchApp.js @@ -84,8 +84,8 @@ exports.addWatchApp = { var resourceFile = proj.addResourceFile('assets.bundle', options); var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); var frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid); + var headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addWatchExtension.js b/test/addWatchExtension.js index 87ea04c..aff8303 100644 --- a/test/addWatchExtension.js +++ b/test/addWatchExtension.js @@ -62,8 +62,8 @@ exports.addWatchExtension = { var resourceFile = proj.addResourceFile('assets.bundle', options); var resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid); var frameworkFile = proj.addFramework('libsqlite3.dylib', options); - frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid), - headerFile = proj.addHeaderFile('file.h', options); + var frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid); + var headerFile = proj.addHeaderFile('file.h', options); test.ok(sourcePhase); test.ok(resourcePhase); diff --git a/test/addXCConfigurationList.js b/test/addXCConfigurationList.js index d2e1c8a..a986691 100644 --- a/test/addXCConfigurationList.js +++ b/test/addXCConfigurationList.js @@ -87,7 +87,7 @@ exports.addXCConfigurationList = { 'should add XCConfigurationList to pbxXCConfigurationListSection': function (test) { var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); var pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); test.ok(pbxXCConfigurationListSection[xcConfigurationList.uuid]); test.done(); @@ -95,8 +95,8 @@ exports.addXCConfigurationList = { 'should add XCConfigurationList object correctly': function (test) { var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); var pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), - xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; test.deepEqual(xcConfigurationListInPbx, xcConfigurationList.xcConfigurationList); test.done(); @@ -104,11 +104,11 @@ exports.addXCConfigurationList = { 'should add correct configurations to XCConfigurationList and to pbxBuildConfigurationSection': function (test) { var myProj = new pbx('test/parser/projects/full.pbxproj').parseSync(); var pbxXCConfigurationListSection = myProj.pbxXCConfigurationList(); - pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(), - xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'), - xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations, - expectedConfigurations = [], - xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; + var pbxBuildConfigurationSection = myProj.pbxXCBuildConfigurationSection(); + var xcConfigurationList = myProj.addXCConfigurationList([debugConfiguration, releaseConfiguration], 'Release', 'XCConfigurationList Comment'); + var xcConfigurationListConfigurations = xcConfigurationList.xcConfigurationList.buildConfigurations; + var expectedConfigurations = []; + var xcConfigurationListInPbx = pbxXCConfigurationListSection[xcConfigurationList.uuid]; for (var index = 0; index < xcConfigurationListConfigurations.length; index++) { var configuration = xcConfigurationListConfigurations[index]; diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index 0d8c003..561452c 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -97,8 +97,8 @@ exports.dataModelDocument = { }, 'should add to resources group by default': function (test) { proj.addDataModelDocument(singleDataModelFilePath); - groupChildren = proj.pbxGroupByName('Resources').children, - found = false; + var groupChildren = proj.pbxGroupByName('Resources').children; + var found = false; for (var index in groupChildren) { if (groupChildren[index].comment === 'single-data-model.xcdatamodeld') { @@ -112,7 +112,7 @@ exports.dataModelDocument = { 'should add to group specified by key': function (test) { var group = 'Frameworks'; proj.addDataModelDocument(singleDataModelFilePath, proj.findPBXGroupKey({ name: group })); - groupChildren = proj.pbxGroupByName(group).children; + var groupChildren = proj.pbxGroupByName(group).children; var found = false; for (var index in groupChildren) { @@ -127,7 +127,7 @@ exports.dataModelDocument = { 'should add to group specified by name': function (test) { var group = 'Frameworks'; proj.addDataModelDocument(singleDataModelFilePath, group); - groupChildren = proj.pbxGroupByName(group).children; + var groupChildren = proj.pbxGroupByName(group).children; var found = false; for (var index in groupChildren) { diff --git a/test/removeFramework.js b/test/removeFramework.js index 370ecf2..7ef6671 100644 --- a/test/removeFramework.js +++ b/test/removeFramework.js @@ -34,9 +34,8 @@ exports.setUp = function (callback) { function nonComments (obj) { var keys = Object.keys(obj); var newObj = {}; - var i = 0; - for (i; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { if (!/_comment$/.test(keys[i])) { newObj[keys[i]] = obj[keys[i]]; } @@ -49,10 +48,9 @@ function frameworkSearchPaths (proj) { var configs = nonComments(proj.pbxXCBuildConfigurationSection()); var allPaths = []; var ids = Object.keys(configs); - var i; var buildSettings; - for (i = 0; i < ids.length; i++) { + for (var i = 0; i < ids.length; i++) { buildSettings = configs[ids[i]].buildSettings; if (buildSettings.FRAMEWORK_SEARCH_PATHS) { @@ -88,8 +86,8 @@ exports.removeFramework = { }, 'should remove 2 fields from the PBXFileReference section': function (test) { var newFile = proj.addFramework('libsqlite3.dylib'); - fileRefSection = proj.pbxFileReferenceSection(), - frsLength = Object.keys(fileRefSection).length; + var fileRefSection = proj.pbxFileReferenceSection(); + var frsLength = Object.keys(fileRefSection).length; test.equal(68, frsLength); test.ok(fileRefSection[newFile.fileRef]); @@ -162,9 +160,9 @@ exports.removeFramework = { test.equal(frameworks.files.length, 15); var frameworkPaths = frameworkSearchPaths(proj); - expectedPath = '"/path/to"'; + var expectedPath = '"/path/to"'; - for (i = 0; i < frameworkPaths.length; i++) { + for (var i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; test.ok(current.indexOf(expectedPath) === -1); } @@ -189,9 +187,9 @@ exports.removeFramework = { test.equal(58, bfsLength); var frameworkPaths = frameworkSearchPaths(proj); - expectedPath = '"/path/to"'; + var expectedPath = '"/path/to"'; - for (i = 0; i < frameworkPaths.length; i++) { + for (var i = 0; i < frameworkPaths.length; i++) { var current = frameworkPaths[i]; test.ok(current.indexOf(expectedPath) === -1); } From fa3e38bd501c0a79cccdc4afe692747c3f03feee Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:33:12 +0900 Subject: [PATCH 09/22] chore: disable eslint rule handle-callback-err for tests --- .eslintrc.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.eslintrc.yml b/.eslintrc.yml index b8e7700..469f6b2 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -23,3 +23,8 @@ ignorePatterns: ['lib/parser/'] rules: new-cap: off + +overrides: + - files: [test/**/*.js] + rules: + handle-callback-err: off From 3447ac84f06676f3bdf88bd64e158caaeafb88fc Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:34:45 +0900 Subject: [PATCH 10/22] chore: fix eslint no-use-before-define problems --- test/dataModelDocument.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index 561452c..51895c9 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -54,8 +54,8 @@ exports.dataModelDocument = { test.done(); }, 'should set an optional target on the pbxFile': function (test) { - var newFile = proj.addDataModelDocument(singleDataModelFilePath, undefined, { target: target }); var target = proj.findTargetKey('TestApp'); + var newFile = proj.addDataModelDocument(singleDataModelFilePath, undefined, { target: target }); test.equal(newFile.target, target); test.done(); From 9d12124c9be2a98d6a8c524f371c19f1770e9b33 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:37:13 +0900 Subject: [PATCH 11/22] chore: fix eslint no-path-concat problems --- lib/pbxProject.js | 2 +- test/dataModelDocument.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index d83cb11..b08de4b 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -38,7 +38,7 @@ function pbxProject (filename) { util.inherits(pbxProject, EventEmitter); pbxProject.prototype.parse = function (cb) { - var worker = fork(__dirname + '/parseJob.js', [this.filepath]); + var worker = fork(path.join(`${__dirname}/parseJob.js`), [this.filepath]); worker.on('message', function (msg) { if (msg.name === 'SyntaxError' || msg.code) { diff --git a/test/dataModelDocument.js b/test/dataModelDocument.js index 51895c9..241f14f 100644 --- a/test/dataModelDocument.js +++ b/test/dataModelDocument.js @@ -22,8 +22,8 @@ var path = require('path'); var pbx = require('../lib/pbxProject'); var pbxFile = require('../lib/pbxFile'); var proj = new pbx('.'); -var singleDataModelFilePath = __dirname + '/fixtures/single-data-model.xcdatamodeld'; -var multipleDataModelFilePath = __dirname + '/fixtures/multiple-data-model.xcdatamodeld'; +var singleDataModelFilePath = path.join(`${__dirname}/fixtures/single-data-model.xcdatamodeld`); +var multipleDataModelFilePath = path.join(`${__dirname}/fixtures/multiple-data-model.xcdatamodeld`); function cleanHash () { return JSON.parse(fullProjectStr); From fd92918b6639a6104c31bda67e742483c009d72c Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:39:51 +0900 Subject: [PATCH 12/22] chore: fix eslint no-template-curly-in-string problems --- test/addXCConfigurationList.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/addXCConfigurationList.js b/test/addXCConfigurationList.js index a986691..acf828e 100644 --- a/test/addXCConfigurationList.js +++ b/test/addXCConfigurationList.js @@ -30,7 +30,7 @@ var debugConfiguration = { ], INFOPLIST_FILE: 'Info.Plist', LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', - PRODUCT_NAME: '"${TARGET_NAME}"', + PRODUCT_NAME: '"${TARGET_NAME}"', // eslint-disable-line SKIP_INSTALL: 'YES' }, name: 'Debug' @@ -41,7 +41,7 @@ var releaseConfiguration = { buildSettings: { INFOPLIST_FILE: 'Info.Plist', LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', - PRODUCT_NAME: '"${TARGET_NAME}"', + PRODUCT_NAME: '"${TARGET_NAME}"', // eslint-disable-line SKIP_INSTALL: 'YES' }, name: 'Release' From 0ea205a8acca5ddeb351ad36987e0d919b24ed0a Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:41:13 +0900 Subject: [PATCH 13/22] chore: fix eslint semi problems --- test/addBuildPhase.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index 340c985..a8ddb57 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -28,20 +28,20 @@ function cleanHash() { exports.setUp = function (callback) { proj.hash = cleanHash(); callback(); -} +}; exports.addBuildPhase = { 'should return a pbxBuildPhase': function (test) { var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); test.ok(typeof buildPhase === 'object'); - test.done() + test.done(); }, 'should set a uuid on the pbxBuildPhase': function (test) { var buildPhase = proj.addBuildPhase(['file.m'], 'PBXSourcesBuildPhase', 'My build phase'); test.ok(buildPhase.uuid); - test.done() + test.done(); }, 'should add all files to build phase': function (test) { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; @@ -50,7 +50,7 @@ exports.addBuildPhase = { test.ok(file.value); } - test.done() + test.done(); }, 'should add the PBXBuildPhase object correctly': function (test) { var buildPhase = proj.addBuildPhase(['file.m', 'assets.bundle'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; @@ -194,4 +194,4 @@ exports.addBuildPhase = { test.equal(buildPhase.shellScript, '"echo \\"hello world!\\""'); test.done(); }, -} +}; From 69da1cd8aef6a3d4f3fc54e8b836dfbdb247fc3a Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:41:43 +0900 Subject: [PATCH 14/22] chore: fix eslint comma-dangle problems --- test/addBuildPhase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index a8ddb57..b87c704 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -193,5 +193,5 @@ exports.addBuildPhase = { test.equal(buildPhase.shellPath, '/bin/sh'); test.equal(buildPhase.shellScript, '"echo \\"hello world!\\""'); test.done(); - }, + } }; From 39aa87b2500545be894ffa544388d97b3db0393f Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:42:39 +0900 Subject: [PATCH 15/22] chore: apply another eslint auto fix --- test/addBuildPhase.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index b87c704..a3e24a3 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -21,7 +21,7 @@ var fullProjectStr = JSON.stringify(fullProject); var pbx = require('../lib/pbxProject'); var proj = new pbx('.'); -function cleanHash() { +function cleanHash () { return JSON.parse(fullProjectStr); } @@ -97,8 +97,8 @@ exports.addBuildPhase = { test.done(); }, 'should not add files to PBXBuildFile section if already added': function (test) { - var buildFileSection = proj.pbxBuildFileSection(); - var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); + var buildFileSection = proj.pbxBuildFileSection(); + var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); @@ -187,8 +187,8 @@ exports.addBuildPhase = { test.equal(buildPhase.dstSubfolderSpec, 13); test.done(); }, - 'should add a script build phase to echo "hello world!"': function(test) { - var options = {shellPath: '/bin/sh', shellScript: 'echo "hello world!"'}; + 'should add a script build phase to echo "hello world!"': function (test) { + var options = { shellPath: '/bin/sh', shellScript: 'echo "hello world!"' }; var buildPhase = proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run a script', proj.getFirstTarget().uuid, options).buildPhase; test.equal(buildPhase.shellPath, '/bin/sh'); test.equal(buildPhase.shellScript, '"echo \\"hello world!\\""'); From f0c4a25e9b141b9c87ae18649aad41e8826f0127 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:43:54 +0900 Subject: [PATCH 16/22] chore: fix eslint no-unused-expressions problems --- test/addBuildPhase.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/addBuildPhase.js b/test/addBuildPhase.js index a3e24a3..c908e07 100644 --- a/test/addBuildPhase.js +++ b/test/addBuildPhase.js @@ -90,7 +90,7 @@ exports.addBuildPhase = { 'should not add files to PBXFileReference section if already added': function (test) { var fileRefSection = proj.pbxFileReferenceSection(); var initialFileReferenceSectionItemsCount = Object.keys(fileRefSection); - proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase'); var afterAdditionBuildFileSectionItemsCount = Object.keys(fileRefSection); test.deepEqual(initialFileReferenceSectionItemsCount, afterAdditionBuildFileSectionItemsCount); @@ -99,7 +99,7 @@ exports.addBuildPhase = { 'should not add files to PBXBuildFile section if already added': function (test) { var buildFileSection = proj.pbxBuildFileSection(); var initialBuildFileSectionItemsCount = Object.keys(buildFileSection); - proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase').buildPhase; + proj.addBuildPhase(['AppDelegate.m', 'main.m'], 'PBXResourcesBuildPhase', 'My build phase'); var afterAdditionBuildFileSectionItemsCount = Object.keys(buildFileSection); test.deepEqual(initialBuildFileSectionItemsCount, afterAdditionBuildFileSectionItemsCount); From 352a21f1987fbaf459054547ed644539014c7106 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:45:41 +0900 Subject: [PATCH 17/22] chore: fix eslint no-prototype-builtins problems --- lib/pbxFile.js | 2 +- test/BuildSettings.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 28bcd1c..0d4f94e 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -104,7 +104,7 @@ function defaultExtension (fileRef) { ? fileRef.lastKnownFileType : fileRef.explicitFileType; for (var extension in FILETYPE_BY_EXTENSION) { - if (FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension))) { + if (Object.prototype.hasOwnProperty.call(FILETYPE_BY_EXTENSION, unquoted(extension))) { if (FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype)) { return extension; } } } diff --git a/test/BuildSettings.js b/test/BuildSettings.js index 4e02b6a..067d30e 100644 --- a/test/BuildSettings.js +++ b/test/BuildSettings.js @@ -51,7 +51,7 @@ exports.addAndRemoveToFromBuildSettings = { var config = proj.pbxXCBuildConfigurationSection(); for (var ref in config) { if (ref.indexOf('_comment') > -1 || config[ref].buildSettings.PRODUCT_NAME !== PRODUCT_NAME) continue; - test.ok(!config[ref].buildSettings.hasOwnProperty(buildSetting)); + test.ok(!Object.prototype.hasOwnProperty.call(config[ref].buildSettings, buildSetting)); } test.done(); } From 6b0900385fdb86f5c7def00868d0918fc24123c3 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:46:29 +0900 Subject: [PATCH 18/22] chore: fix eslint no-new-object problems --- lib/pbxProject.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index b08de4b..d59b05f 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -880,7 +880,7 @@ pbxProject.prototype.addBuildPhase = function (filePathsArray, buildPhaseType, c } if (!this.hash.project.objects[buildPhaseType]) { - this.hash.project.objects[buildPhaseType] = new Object(); + this.hash.project.objects[buildPhaseType] = {}; } if (!this.hash.project.objects[buildPhaseType][buildPhaseUuid]) { @@ -1801,7 +1801,7 @@ pbxProject.prototype.pbxCreateGroupWithType = function (name, pathName, groupTyp // add obj and commentObj to groups; var groups = this.hash.project.objects[groupType]; if (!groups) { - groups = this.hash.project.objects[groupType] = new Object(); + groups = this.hash.project.objects[groupType] = {}; } groups[commendId] = name; groups[key] = model; From 9565162ce02e9c4db45da3a8e9843131021a7257 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:47:01 +0900 Subject: [PATCH 19/22] chore: fix eslint no-redeclare problems --- lib/pbxProject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index d59b05f..9f6ce21 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -1361,7 +1361,7 @@ pbxProject.prototype.__defineGetter__('productName', function () { pbxProject.prototype.hasFile = function (filePath) { var files = nonComments(this.pbxFileReferenceSection()); var file; - var id; + for (var id in files) { file = files[id]; if (file.path === filePath || file.path === ('"' + filePath + '"')) { From 583a72521b58548617398d4049249763b8963e3e Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:49:43 +0900 Subject: [PATCH 20/22] chore: fix eslint no-mixed-operators problems --- lib/pbxProject.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 9f6ce21..5913e04 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -1097,8 +1097,7 @@ pbxProject.prototype.removeBuildProperty = function (prop, build_name) { for (key in configurations) { configuration = configurations[key]; - if (configuration.buildSettings[prop] && - !build_name || configuration.name === build_name) { + if ((configuration.buildSettings[prop] && !build_name) || configuration.name === build_name) { delete configuration.buildSettings[prop]; } } From dfe6429b775526ade8f1aac07d8f66c4e1872813 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 2 Apr 2020 18:50:09 +0900 Subject: [PATCH 21/22] chore: fix eslint no-dupe-keys problems --- lib/pbxFile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 0d4f94e..d926be2 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -73,7 +73,6 @@ var SOURCETREE_BY_FILETYPE = { }; var ENCODING_BY_FILETYPE = { - 'sourcecode.c.h': 4, 'sourcecode.c.h': 4, 'sourcecode.c.objc': 4, 'sourcecode.swift': 4, From c2883242a2e43281ba79dcc4cb9bbefdad868757 Mon Sep 17 00:00:00 2001 From: Erisu Date: Fri, 3 Apr 2020 20:28:13 +0900 Subject: [PATCH 22/22] refactor: transform var to let & const --- lib/parseJob.js | 10 +- lib/pbxFile.js | 48 ++-- lib/pbxProject.js | 596 +++++++++++++++++++++++----------------------- lib/pbxWriter.js | 58 ++--- 4 files changed, 356 insertions(+), 356 deletions(-) diff --git a/lib/parseJob.js b/lib/parseJob.js index e3d9260..c6ad8f0 100644 --- a/lib/parseJob.js +++ b/lib/parseJob.js @@ -17,12 +17,12 @@ // parsing is slow and blocking right now // so we do it in a separate process -var fs = require('fs'); +const fs = require('fs'); -var parser = require('./parser/pbxproj'); -var path = process.argv[2]; -var fileContents; -var obj; +const parser = require('./parser/pbxproj'); +const path = process.argv[2]; +let fileContents; +let obj; try { fileContents = fs.readFileSync(path, 'utf-8'); diff --git a/lib/pbxFile.js b/lib/pbxFile.js index d926be2..e9bb67e 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -15,15 +15,15 @@ under the License. */ -var path = require('path'); +const path = require('path'); -var util = require('util'); -var DEFAULT_SOURCETREE = '""'; -var DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR'; -var DEFAULT_GROUP = 'Resources'; -var DEFAULT_FILETYPE = 'unknown'; +const util = require('util'); +const DEFAULT_SOURCETREE = '""'; +const DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR'; +const DEFAULT_GROUP = 'Resources'; +const DEFAULT_FILETYPE = 'unknown'; -var FILETYPE_BY_EXTENSION = { +const FILETYPE_BY_EXTENSION = { a: 'archive.ar', app: 'wrapper.application', appex: 'wrapper.app-extension', @@ -49,7 +49,7 @@ var FILETYPE_BY_EXTENSION = { strings: 'text.plist.strings' }; -var GROUP_BY_FILETYPE = { +const GROUP_BY_FILETYPE = { 'archive.ar': 'Frameworks', 'compiled.mach-o.dylib': 'Frameworks', 'sourcecode.text-based-dylib-definition': 'Frameworks', @@ -60,19 +60,19 @@ var GROUP_BY_FILETYPE = { 'sourcecode.swift': 'Sources' }; -var PATH_BY_FILETYPE = { +const PATH_BY_FILETYPE = { 'compiled.mach-o.dylib': 'usr/lib/', 'sourcecode.text-based-dylib-definition': 'usr/lib/', 'wrapper.framework': 'System/Library/Frameworks/' }; -var SOURCETREE_BY_FILETYPE = { +const SOURCETREE_BY_FILETYPE = { 'compiled.mach-o.dylib': 'SDKROOT', 'sourcecode.text-based-dylib-definition': 'SDKROOT', 'wrapper.framework': 'SDKROOT' }; -var ENCODING_BY_FILETYPE = { +const ENCODING_BY_FILETYPE = { 'sourcecode.c.h': 4, 'sourcecode.c.objc': 4, 'sourcecode.swift': 4, @@ -88,8 +88,8 @@ function unquoted (text) { } function detectType (filePath) { - var extension = path.extname(filePath).substring(1); - var filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; + const extension = path.extname(filePath).substring(1); + const filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; if (!filetype) { return DEFAULT_FILETYPE; @@ -99,10 +99,10 @@ function detectType (filePath) { } function defaultExtension (fileRef) { - var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType !== DEFAULT_FILETYPE + const filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType !== DEFAULT_FILETYPE ? fileRef.lastKnownFileType : fileRef.explicitFileType; - for (var extension in FILETYPE_BY_EXTENSION) { + for (const extension in FILETYPE_BY_EXTENSION) { if (Object.prototype.hasOwnProperty.call(FILETYPE_BY_EXTENSION, unquoted(extension))) { if (FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype)) { return extension; } } @@ -110,8 +110,8 @@ function defaultExtension (fileRef) { } function defaultEncoding (fileRef) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; - var encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; + const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + const encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; if (encoding) { return encoding; @@ -119,9 +119,9 @@ function defaultEncoding (fileRef) { } function detectGroup (fileRef, opt) { - var extension = path.extname(fileRef.basename).substring(1); - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; - var groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; + const extension = path.extname(fileRef.basename).substring(1); + const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + const groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; if (extension === 'xcdatamodeld') { return 'Sources'; @@ -139,8 +139,8 @@ function detectGroup (fileRef, opt) { } function detectSourcetree (fileRef) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; - var sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; + const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + const sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; if (fileRef.explicitFileType) { return DEFAULT_PRODUCT_SOURCETREE; @@ -158,8 +158,8 @@ function detectSourcetree (fileRef) { } function defaultPath (fileRef, filePath) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; - var defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; + const filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; + const defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; if (fileRef.customFramework) { return filePath; diff --git a/lib/pbxProject.js b/lib/pbxProject.js index 5913e04..7cca1d9 100644 --- a/lib/pbxProject.js +++ b/lib/pbxProject.js @@ -15,19 +15,19 @@ under the License. */ -var util = require('util'); - -var f = util.format; -var EventEmitter = require('events').EventEmitter; -var path = require('path'); -var uuid = require('uuid'); -var fork = require('child_process').fork; -var pbxWriter = require('./pbxWriter'); -var pbxFile = require('./pbxFile'); -var fs = require('fs'); -var parser = require('./parser/pbxproj'); -var plist = require('simple-plist'); -var COMMENT_KEY = /_comment$/; +const util = require('util'); + +const f = util.format; +const EventEmitter = require('events').EventEmitter; +const path = require('path'); +const uuid = require('uuid'); +const fork = require('child_process').fork; +const pbxWriter = require('./pbxWriter'); +const pbxFile = require('./pbxFile'); +const fs = require('fs'); +const parser = require('./parser/pbxproj'); +const plist = require('simple-plist'); +const COMMENT_KEY = /_comment$/; function pbxProject (filename) { if (!(this instanceof pbxProject)) { return new pbxProject(filename); } @@ -38,7 +38,7 @@ function pbxProject (filename) { util.inherits(pbxProject, EventEmitter); pbxProject.prototype.parse = function (cb) { - var worker = fork(path.join(`${__dirname}/parseJob.js`), [this.filepath]); + const worker = fork(path.join(`${__dirname}/parseJob.js`), [this.filepath]); worker.on('message', function (msg) { if (msg.name === 'SyntaxError' || msg.code) { @@ -58,7 +58,7 @@ pbxProject.prototype.parse = function (cb) { }; pbxProject.prototype.parseSync = function () { - var file_contents = fs.readFileSync(this.filepath, 'utf-8'); + const file_contents = fs.readFileSync(this.filepath, 'utf-8'); this.hash = parser.parse(file_contents); return this; @@ -70,11 +70,11 @@ pbxProject.prototype.writeSync = function (options) { }; pbxProject.prototype.allUuids = function () { - var sections = this.hash.project.objects; - var uuids = []; - var section; + const sections = this.hash.project.objects; + let uuids = []; + let section; - for (var key in sections) { + for (const key in sections) { section = sections[key]; uuids = uuids.concat(Object.keys(section)); } @@ -87,7 +87,7 @@ pbxProject.prototype.allUuids = function () { }; pbxProject.prototype.generateUuid = function () { - var id = uuid.v4() + const id = uuid.v4() .replace(/-/g, '') .substr(0, 24) .toUpperCase(); @@ -100,7 +100,7 @@ pbxProject.prototype.generateUuid = function () { }; pbxProject.prototype.addPluginFile = function (path, opt) { - var file = new pbxFile(path, opt); + const file = new pbxFile(path, opt); file.plugin = true; // durr correctForPluginsPath(file, this); @@ -117,7 +117,7 @@ pbxProject.prototype.addPluginFile = function (path, opt) { }; pbxProject.prototype.removePluginFile = function (path, opt) { - var file = new pbxFile(path, opt); + const file = new pbxFile(path, opt); correctForPluginsPath(file, this); this.removeFromPbxFileReferenceSection(file); // PBXFileReference @@ -127,7 +127,7 @@ pbxProject.prototype.removePluginFile = function (path, opt) { }; pbxProject.prototype.addProductFile = function (targetPath, opt) { - var file = new pbxFile(targetPath, opt); + const file = new pbxFile(targetPath, opt); file.includeInIndex = 0; file.fileRef = this.generateUuid(); @@ -143,7 +143,7 @@ pbxProject.prototype.addProductFile = function (targetPath, opt) { }; pbxProject.prototype.removeProductFile = function (path, opt) { - var file = new pbxFile(path, opt); + const file = new pbxFile(path, opt); this.removeFromProductsPbxGroup(file); // PBXGroup @@ -158,7 +158,7 @@ pbxProject.prototype.removeProductFile = function (path, opt) { * @returns {Object} file; see pbxFile */ pbxProject.prototype.addSourceFile = function (path, opt, group) { - var file; + let file; if (group) { file = this.addFile(path, group, opt); } else { @@ -184,7 +184,7 @@ pbxProject.prototype.addSourceFile = function (path, opt, group) { * @returns {Object} file; see pbxFile */ pbxProject.prototype.removeSourceFile = function (path, opt, group) { - var file; + let file; if (group) { file = this.removeFile(path, group, opt); } else { @@ -237,7 +237,7 @@ pbxProject.prototype.removeHeaderFile = function (path, opt, group) { pbxProject.prototype.addResourceFile = function (path, opt, group) { opt = opt || {}; - var file; + let file; if (opt.plugin) { file = this.addPluginFile(path, opt); @@ -284,7 +284,7 @@ pbxProject.prototype.addResourceFile = function (path, opt, group) { * @returns {Object} file; see pbxFile */ pbxProject.prototype.removeResourceFile = function (path, opt, group) { - var file = new pbxFile(path, opt); + const file = new pbxFile(path, opt); file.target = opt ? opt.target : undefined; correctForResourcesPath(file, this); @@ -306,15 +306,15 @@ pbxProject.prototype.removeResourceFile = function (path, opt, group) { }; pbxProject.prototype.addFramework = function (fpath, opt) { - var customFramework = opt && opt.customFramework === true; - var link = !opt || (opt.link === undefined || opt.link); // defaults to true if not specified - var embed = opt && opt.embed; // defaults to false if not specified + const customFramework = opt && opt.customFramework === true; + const link = !opt || (opt.link === undefined || opt.link); // defaults to true if not specified + const embed = opt && opt.embed; // defaults to false if not specified if (opt) { delete opt.embed; } - var file = new pbxFile(fpath, opt); + const file = new pbxFile(fpath, opt); file.uuid = this.generateUuid(); file.fileRef = this.generateUuid(); @@ -335,7 +335,7 @@ pbxProject.prototype.addFramework = function (fpath, opt) { if (embed) { opt.embed = embed; - var embeddedFile = new pbxFile(fpath, opt); + const embeddedFile = new pbxFile(fpath, opt); embeddedFile.uuid = this.generateUuid(); embeddedFile.fileRef = file.fileRef; @@ -357,7 +357,7 @@ pbxProject.prototype.removeFramework = function (fpath, opt) { delete opt.embed; } - var file = new pbxFile(fpath, opt); + const file = new pbxFile(fpath, opt); file.target = opt ? opt.target : undefined; this.removeFromPbxBuildFileSection(file); // PBXBuildFile @@ -371,7 +371,7 @@ pbxProject.prototype.removeFramework = function (fpath, opt) { opt = opt || {}; opt.embed = true; - var embeddedFile = new pbxFile(fpath, opt); + const embeddedFile = new pbxFile(fpath, opt); embeddedFile.fileRef = file.fileRef; @@ -382,7 +382,7 @@ pbxProject.prototype.removeFramework = function (fpath, opt) { }; pbxProject.prototype.addCopyfile = function (fpath, opt) { - var file = new pbxFile(fpath, opt); + let file = new pbxFile(fpath, opt); // catch duplicates if (this.hasFile(file.path)) { @@ -404,12 +404,12 @@ pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function (target) { }; pbxProject.prototype.addToPbxCopyfilesBuildPhase = function (file) { - var sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target); + const sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target); sources.files.push(pbxBuildPhaseObj(file)); }; pbxProject.prototype.removeCopyfile = function (fpath, opt) { - var file = new pbxFile(fpath, opt); + const file = new pbxFile(fpath, opt); file.target = opt ? opt.target : undefined; this.removeFromPbxBuildFileSection(file); // PBXBuildFile @@ -420,8 +420,8 @@ pbxProject.prototype.removeCopyfile = function (fpath, opt) { }; pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function (file) { - var sources = this.pbxCopyfilesBuildPhaseObj(file.target); - for (var i in sources.files) { + const sources = this.pbxCopyfilesBuildPhaseObj(file.target); + for (const i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -432,7 +432,7 @@ pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function (file) { pbxProject.prototype.addStaticLibrary = function (path, opt) { opt = opt || {}; - var file; + let file; if (opt.plugin) { file = this.addPluginFile(path, opt); @@ -459,32 +459,32 @@ pbxProject.prototype.addStaticLibrary = function (path, opt) { // helper addition functions pbxProject.prototype.addToPbxBuildFileSection = function (file) { - var commentKey = f('%s_comment', file.uuid); + const commentKey = f('%s_comment', file.uuid); this.pbxBuildFileSection()[file.uuid] = pbxBuildFileObj(file); this.pbxBuildFileSection()[commentKey] = pbxBuildFileComment(file); }; pbxProject.prototype.removeFromPbxBuildFileSection = function (file) { - var uuid; + let uuid; for (uuid in this.pbxBuildFileSection()) { if (this.pbxBuildFileSection()[uuid].fileRef_comment === file.basename) { file.uuid = uuid; delete this.pbxBuildFileSection()[uuid]; - var commentKey = f('%s_comment', uuid); + const commentKey = f('%s_comment', uuid); delete this.pbxBuildFileSection()[commentKey]; } } }; pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceTree) { - var groups = this.hash.project.objects.PBXGroup; - var pbxGroupUuid = this.generateUuid(); - var commentKey = f('%s_comment', pbxGroupUuid); + const groups = this.hash.project.objects.PBXGroup; + const pbxGroupUuid = this.generateUuid(); + const commentKey = f('%s_comment', pbxGroupUuid); - var pbxGroup = { + const pbxGroup = { isa: 'PBXGroup', children: [], name: name, @@ -492,22 +492,22 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT sourceTree: sourceTree || '""' }; - var fileReferenceSection = this.pbxFileReferenceSection(); - var filePathToReference = {}; + const fileReferenceSection = this.pbxFileReferenceSection(); + const filePathToReference = {}; - for (var key in fileReferenceSection) { + for (const key in fileReferenceSection) { // only look for comments if (!COMMENT_KEY.test(key)) continue; - var fileReferenceKey = key.split(COMMENT_KEY)[0]; - var fileReference = fileReferenceSection[fileReferenceKey]; + const fileReferenceKey = key.split(COMMENT_KEY)[0]; + const fileReference = fileReferenceSection[fileReferenceKey]; filePathToReference[fileReference.path] = { fileRef: fileReferenceKey, basename: fileReferenceSection[key] }; } - for (var index = 0; index < filePathsArray.length; index++) { - var filePath = filePathsArray[index]; - var filePathQuoted = '"' + filePath + '"'; + for (let index = 0; index < filePathsArray.length; index++) { + const filePath = filePathsArray[index]; + const filePathQuoted = '"' + filePath + '"'; if (filePathToReference[filePath]) { pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath])); continue; @@ -516,7 +516,7 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT continue; } - var file = new pbxFile(filePath); + const file = new pbxFile(filePath); file.uuid = this.generateUuid(); file.fileRef = this.generateUuid(); this.addToPbxFileReferenceSection(file); // PBXFileReference @@ -533,9 +533,9 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT }; pbxProject.prototype.removePbxGroup = function (groupName) { - var section = this.hash.project.objects.PBXGroup; - var key; - var itemKey; + const section = this.hash.project.objects.PBXGroup; + let key; + let itemKey; for (key in section) { // only look for comments @@ -549,7 +549,7 @@ pbxProject.prototype.removePbxGroup = function (groupName) { }; pbxProject.prototype.addToPbxProjectSection = function (target) { - var newTarget = { + const newTarget = { value: target.uuid, comment: pbxNativeTargetComment(target.pbxNativeTarget) }; @@ -558,22 +558,22 @@ pbxProject.prototype.addToPbxProjectSection = function (target) { }; pbxProject.prototype.addToPbxNativeTargetSection = function (target) { - var commentKey = f('%s_comment', target.uuid); + const commentKey = f('%s_comment', target.uuid); this.pbxNativeTargetSection()[target.uuid] = target.pbxNativeTarget; this.pbxNativeTargetSection()[commentKey] = target.pbxNativeTarget.name; }; pbxProject.prototype.addToPbxFileReferenceSection = function (file) { - var commentKey = f('%s_comment', file.fileRef); + const commentKey = f('%s_comment', file.fileRef); this.pbxFileReferenceSection()[file.fileRef] = pbxFileReferenceObj(file); this.pbxFileReferenceSection()[commentKey] = pbxFileReferenceComment(file); }; pbxProject.prototype.removeFromPbxFileReferenceSection = function (file) { - var refObj = pbxFileReferenceObj(file); - for (var i in this.pbxFileReferenceSection()) { + const refObj = pbxFileReferenceObj(file); + for (const i in this.pbxFileReferenceSection()) { if (this.pbxFileReferenceSection()[i].name === refObj.name || ('"' + this.pbxFileReferenceSection()[i].name + '"') === refObj.name || this.pbxFileReferenceSection()[i].path === refObj.path || @@ -583,7 +583,7 @@ pbxProject.prototype.removeFromPbxFileReferenceSection = function (file) { break; } } - var commentKey = f('%s_comment', file.fileRef); + const commentKey = f('%s_comment', file.fileRef); if (this.pbxFileReferenceSection()[commentKey] !== undefined) { delete this.pbxFileReferenceSection()[commentKey]; } @@ -596,7 +596,7 @@ pbxProject.prototype.addToXcVersionGroupSection = function (file) { throw new Error('Cannot create a XCVersionGroup section from not a data model document file'); } - var commentKey = f('%s_comment', file.fileRef); + const commentKey = f('%s_comment', file.fileRef); if (!this.xcVersionGroupSection()[file.fileRef]) { this.xcVersionGroupSection()[file.fileRef] = { @@ -613,7 +613,7 @@ pbxProject.prototype.addToXcVersionGroupSection = function (file) { }; pbxProject.prototype.addToPluginsPbxGroup = function (file) { - var pluginsGroup = this.pbxGroupByName('Plugins'); + const pluginsGroup = this.pbxGroupByName('Plugins'); if (!pluginsGroup) { this.addPbxGroup([file.path], 'Plugins'); } else { @@ -625,8 +625,8 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function (file) { if (!this.pbxGroupByName('Plugins')) { return null; } - var pluginsGroupChildren = this.pbxGroupByName('Plugins').children; - for (var i in pluginsGroupChildren) { + const pluginsGroupChildren = this.pbxGroupByName('Plugins').children; + for (const i in pluginsGroupChildren) { if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -636,7 +636,7 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function (file) { }; pbxProject.prototype.addToResourcesPbxGroup = function (file) { - var pluginsGroup = this.pbxGroupByName('Resources'); + const pluginsGroup = this.pbxGroupByName('Resources'); if (!pluginsGroup) { this.addPbxGroup([file.path], 'Resources'); } else { @@ -648,8 +648,8 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function (file) { if (!this.pbxGroupByName('Resources')) { return null; } - var pluginsGroupChildren = this.pbxGroupByName('Resources').children; - for (var i in pluginsGroupChildren) { + const pluginsGroupChildren = this.pbxGroupByName('Resources').children; + for (const i in pluginsGroupChildren) { if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -659,7 +659,7 @@ pbxProject.prototype.removeFromResourcesPbxGroup = function (file) { }; pbxProject.prototype.addToFrameworksPbxGroup = function (file) { - var pluginsGroup = this.pbxGroupByName('Frameworks'); + const pluginsGroup = this.pbxGroupByName('Frameworks'); if (!pluginsGroup) { this.addPbxGroup([file.path], 'Frameworks'); } else { @@ -671,9 +671,9 @@ pbxProject.prototype.removeFromFrameworksPbxGroup = function (file) { if (!this.pbxGroupByName('Frameworks')) { return null; } - var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; + const pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; - for (var i in pluginsGroupChildren) { + for (const i in pluginsGroupChildren) { if (pbxGroupChild(file).value === pluginsGroupChildren[i].value && pbxGroupChild(file).comment === pluginsGroupChildren[i].comment) { pluginsGroupChildren.splice(i, 1); @@ -683,17 +683,17 @@ pbxProject.prototype.removeFromFrameworksPbxGroup = function (file) { }; pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) { - var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); + const sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); if (sources) { sources.files.push(pbxBuildPhaseObj(file)); } }; pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { - var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); + const sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); if (sources) { - var files = []; - for (var i in sources.files) { + const files = []; + for (const i in sources.files) { if (sources.files[i].comment !== longComment(file)) { files.push(sources.files[i]); } @@ -703,7 +703,7 @@ pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { }; pbxProject.prototype.addToProductsPbxGroup = function (file) { - var productsGroup = this.pbxGroupByName('Products'); + const productsGroup = this.pbxGroupByName('Products'); if (!productsGroup) { this.addPbxGroup([file.path], 'Products'); } else { @@ -715,8 +715,8 @@ pbxProject.prototype.removeFromProductsPbxGroup = function (file) { if (!this.pbxGroupByName('Products')) { return null; } - var productsGroupChildren = this.pbxGroupByName('Products').children; - for (var i in productsGroupChildren) { + const productsGroupChildren = this.pbxGroupByName('Products').children; + for (const i in productsGroupChildren) { if (pbxGroupChild(file).value === productsGroupChildren[i].value && pbxGroupChild(file).comment === productsGroupChildren[i].comment) { productsGroupChildren.splice(i, 1); @@ -726,13 +726,13 @@ pbxProject.prototype.removeFromProductsPbxGroup = function (file) { }; pbxProject.prototype.addToPbxSourcesBuildPhase = function (file) { - var sources = this.pbxSourcesBuildPhaseObj(file.target); + const sources = this.pbxSourcesBuildPhaseObj(file.target); sources.files.push(pbxBuildPhaseObj(file)); }; pbxProject.prototype.removeFromPbxSourcesBuildPhase = function (file) { - var sources = this.pbxSourcesBuildPhaseObj(file.target); - for (var i in sources.files) { + const sources = this.pbxSourcesBuildPhaseObj(file.target); + for (const i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -741,14 +741,14 @@ pbxProject.prototype.removeFromPbxSourcesBuildPhase = function (file) { }; pbxProject.prototype.addToPbxResourcesBuildPhase = function (file) { - var sources = this.pbxResourcesBuildPhaseObj(file.target); + const sources = this.pbxResourcesBuildPhaseObj(file.target); sources.files.push(pbxBuildPhaseObj(file)); }; pbxProject.prototype.removeFromPbxResourcesBuildPhase = function (file) { - var sources = this.pbxResourcesBuildPhaseObj(file.target); + const sources = this.pbxResourcesBuildPhaseObj(file.target); - for (var i in sources.files) { + for (const i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -757,13 +757,13 @@ pbxProject.prototype.removeFromPbxResourcesBuildPhase = function (file) { }; pbxProject.prototype.addToPbxFrameworksBuildPhase = function (file) { - var sources = this.pbxFrameworksBuildPhaseObj(file.target); + const sources = this.pbxFrameworksBuildPhaseObj(file.target); sources.files.push(pbxBuildPhaseObj(file)); }; pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function (file) { - var sources = this.pbxFrameworksBuildPhaseObj(file.target); - for (var i in sources.files) { + const sources = this.pbxFrameworksBuildPhaseObj(file.target); + for (const i in sources.files) { if (sources.files[i].comment === longComment(file)) { sources.files.splice(i, 1); break; @@ -772,22 +772,22 @@ pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function (file) { }; pbxProject.prototype.addXCConfigurationList = function (configurationObjectsArray, defaultConfigurationName, comment) { - var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(); - var pbxXCConfigurationListSection = this.pbxXCConfigurationList(); - var xcConfigurationListUuid = this.generateUuid(); - var commentKey = f('%s_comment', xcConfigurationListUuid); + const pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(); + const pbxXCConfigurationListSection = this.pbxXCConfigurationList(); + const xcConfigurationListUuid = this.generateUuid(); + const commentKey = f('%s_comment', xcConfigurationListUuid); - var xcConfigurationList = { + const xcConfigurationList = { isa: 'XCConfigurationList', buildConfigurations: [], defaultConfigurationIsVisible: 0, defaultConfigurationName: defaultConfigurationName }; - for (var index = 0; index < configurationObjectsArray.length; index++) { - var configuration = configurationObjectsArray[index]; - var configurationUuid = this.generateUuid(); - var configurationCommentKey = f('%s_comment', configurationUuid); + for (let index = 0; index < configurationObjectsArray.length; index++) { + const configuration = configurationObjectsArray[index]; + const configurationUuid = this.generateUuid(); + const configurationCommentKey = f('%s_comment', configurationUuid); pbxBuildConfigurationSection[configurationUuid] = configuration; pbxBuildConfigurationSection[configurationCommentKey] = configuration.name; @@ -805,29 +805,29 @@ pbxProject.prototype.addXCConfigurationList = function (configurationObjectsArra pbxProject.prototype.addTargetDependency = function (target, dependencyTargets) { if (!target) { return undefined; } - var nativeTargets = this.pbxNativeTargetSection(); + const nativeTargets = this.pbxNativeTargetSection(); if (typeof nativeTargets[target] === 'undefined') { throw new Error('Invalid target: ' + target); } - for (var index = 0; index < dependencyTargets.length; index++) { - var dependencyTarget = dependencyTargets[index]; + for (let index = 0; index < dependencyTargets.length; index++) { + const dependencyTarget = dependencyTargets[index]; if (typeof nativeTargets[dependencyTarget] === 'undefined') { throw new Error('Invalid target: ' + dependencyTarget); } } - var pbxTargetDependency = 'PBXTargetDependency'; - var pbxContainerItemProxy = 'PBXContainerItemProxy'; - var pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency]; - var pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; + const pbxTargetDependency = 'PBXTargetDependency'; + const pbxContainerItemProxy = 'PBXContainerItemProxy'; + const pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency]; + const pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; - for (var index2 = 0; index2 < dependencyTargets.length; index2++) { - var dependencyTargetUuid = dependencyTargets[index2]; - var dependencyTargetCommentKey = f('%s_comment', dependencyTargetUuid); - var targetDependencyUuid = this.generateUuid(); - var targetDependencyCommentKey = f('%s_comment', targetDependencyUuid); - var itemProxyUuid = this.generateUuid(); - var itemProxyCommentKey = f('%s_comment', itemProxyUuid); + for (let index2 = 0; index2 < dependencyTargets.length; index2++) { + const dependencyTargetUuid = dependencyTargets[index2]; + const dependencyTargetCommentKey = f('%s_comment', dependencyTargetUuid); + const targetDependencyUuid = this.generateUuid(); + const targetDependencyCommentKey = f('%s_comment', targetDependencyUuid); + const itemProxyUuid = this.generateUuid(); + const itemProxyCommentKey = f('%s_comment', itemProxyUuid); - var itemProxy = { + const itemProxy = { isa: pbxContainerItemProxy, containerPortal: this.hash.project.rootObject, containerPortal_comment: this.hash.project.rootObject_comment, @@ -836,7 +836,7 @@ pbxProject.prototype.addTargetDependency = function (target, dependencyTargets) remoteInfo: nativeTargets[dependencyTargetUuid].name }; - var targetDependency = { + const targetDependency = { isa: pbxTargetDependency, target: dependencyTargetUuid, target_comment: nativeTargets[dependencyTargetCommentKey], @@ -857,21 +857,21 @@ pbxProject.prototype.addTargetDependency = function (target, dependencyTargets) }; pbxProject.prototype.addBuildPhase = function (filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) { - var buildPhaseSection; - var fileReferenceSection = this.pbxFileReferenceSection(); - var buildFileSection = this.pbxBuildFileSection(); - var buildPhaseUuid = this.generateUuid(); - var buildPhaseTargetUuid = target || this.getFirstTarget().uuid; - var commentKey = f('%s_comment', buildPhaseUuid); - - var buildPhase = { + let buildPhaseSection; + const fileReferenceSection = this.pbxFileReferenceSection(); + const buildFileSection = this.pbxBuildFileSection(); + const buildPhaseUuid = this.generateUuid(); + const buildPhaseTargetUuid = target || this.getFirstTarget().uuid; + const commentKey = f('%s_comment', buildPhaseUuid); + + let buildPhase = { isa: buildPhaseType, buildActionMask: 2147483647, files: [], runOnlyForDeploymentPostprocessing: 0 }; - var filePathToBuildFile = {}; + const filePathToBuildFile = {}; if (buildPhaseType === 'PBXCopyFilesBuildPhase') { buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment); @@ -895,25 +895,25 @@ pbxProject.prototype.addBuildPhase = function (filePathsArray, buildPhaseType, c }); } - for (var key in buildFileSection) { + for (const key in buildFileSection) { // only look for comments if (!COMMENT_KEY.test(key)) continue; - var buildFileKey = key.split(COMMENT_KEY)[0]; - var buildFile = buildFileSection[buildFileKey]; - var fileReference = fileReferenceSection[buildFile.fileRef]; + const buildFileKey = key.split(COMMENT_KEY)[0]; + const buildFile = buildFileSection[buildFileKey]; + const fileReference = fileReferenceSection[buildFile.fileRef]; if (!fileReference) continue; - var pbxFileObj = new pbxFile(fileReference.path); + const pbxFileObj = new pbxFile(fileReference.path); filePathToBuildFile[fileReference.path] = { uuid: buildFileKey, basename: pbxFileObj.basename, group: pbxFileObj.group }; } - for (var index = 0; index < filePathsArray.length; index++) { - var filePath = filePathsArray[index]; - var filePathQuoted = '"' + filePath + '"'; - var file = new pbxFile(filePath); + for (let index = 0; index < filePathsArray.length; index++) { + const filePath = filePathsArray[index]; + const filePathQuoted = '"' + filePath + '"'; + const file = new pbxFile(filePath); if (filePathToBuildFile[filePath]) { buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePath])); @@ -971,9 +971,9 @@ pbxProject.prototype.pbxXCConfigurationList = function () { }; pbxProject.prototype.pbxGroupByName = function (name) { - var groups = this.hash.project.objects.PBXGroup; - var key; - var groupKey; + const groups = this.hash.project.objects.PBXGroup; + let key; + let groupKey; for (key in groups) { // only look for comments @@ -993,13 +993,13 @@ pbxProject.prototype.pbxTargetByName = function (name) { }; pbxProject.prototype.findTargetKey = function (name) { - var targets = this.hash.project.objects.PBXNativeTarget; + const targets = this.hash.project.objects.PBXNativeTarget; - for (var key in targets) { + for (const key in targets) { // only look for comments if (COMMENT_KEY.test(key)) continue; - var target = targets[key]; + const target = targets[key]; if (target.name === name) { return key; } @@ -1009,9 +1009,9 @@ pbxProject.prototype.findTargetKey = function (name) { }; pbxProject.prototype.pbxItemByComment = function (name, pbxSectionName) { - var section = this.hash.project.objects[pbxSectionName]; - var key; - var itemKey; + const section = this.hash.project.objects[pbxSectionName]; + let key; + let itemKey; for (key in section) { // only look for comments @@ -1046,22 +1046,22 @@ pbxProject.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) { pbxProject.prototype.buildPhase = function (group, target) { if (!target) { return undefined; } - var nativeTargets = this.pbxNativeTargetSection(); + const nativeTargets = this.pbxNativeTargetSection(); if (typeof nativeTargets[target] === 'undefined') { throw new Error('Invalid target: ' + target); } - var nativeTarget = nativeTargets[target]; - var buildPhases = nativeTarget.buildPhases; - for (var i in buildPhases) { - var buildPhase = buildPhases[i]; + const nativeTarget = nativeTargets[target]; + const buildPhases = nativeTarget.buildPhases; + for (const i in buildPhases) { + const buildPhase = buildPhases[i]; if (buildPhase.comment === group) { return buildPhase.value + '_comment'; } } }; pbxProject.prototype.buildPhaseObject = function (name, group, target) { - var section = this.hash.project.objects[name]; - var sectionKey; - var key; - var buildPhase = this.buildPhase(group, target); + const section = this.hash.project.objects[name]; + let sectionKey; + let key; + const buildPhase = this.buildPhase(group, target); for (key in section) { // only look for comments @@ -1078,9 +1078,9 @@ pbxProject.prototype.buildPhaseObject = function (name, group, target) { }; pbxProject.prototype.addBuildProperty = function (prop, value, build_name) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var key; - var configuration; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + let key; + let configuration; for (key in configurations) { configuration = configurations[key]; @@ -1091,9 +1091,9 @@ pbxProject.prototype.addBuildProperty = function (prop, value, build_name) { }; pbxProject.prototype.removeBuildProperty = function (prop, build_name) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var key; - var configuration; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + let key; + let configuration; for (key in configurations) { configuration = configurations[key]; @@ -1110,10 +1110,10 @@ pbxProject.prototype.removeBuildProperty = function (prop, build_name) { * @param build {String} Release or Debug */ pbxProject.prototype.updateBuildProperty = function (prop, value, build) { - var configs = this.pbxXCBuildConfigurationSection(); - for (var configName in configs) { + const configs = this.pbxXCBuildConfigurationSection(); + for (const configName in configs) { if (!COMMENT_KEY.test(configName)) { - var config = configs[configName]; + const config = configs[configName]; if ((build && config.name === build) || (!build)) { config.buildSettings[prop] = value; } @@ -1126,12 +1126,12 @@ pbxProject.prototype.updateProductName = function (name) { }; pbxProject.prototype.removeFromFrameworkSearchPaths = function (file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS'; - var config; - var buildSettings; - var searchPaths; - var new_path = searchPathForFile(file, this); + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS'; + let config; + let buildSettings; + let searchPaths; + const new_path = searchPathForFile(file, this); for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1141,11 +1141,11 @@ pbxProject.prototype.removeFromFrameworkSearchPaths = function (file) { searchPaths = buildSettings[SEARCH_PATHS]; if (searchPaths && Array.isArray(searchPaths)) { - var matches = searchPaths.filter(function (p) { + const matches = searchPaths.filter(function (p) { return p.indexOf(new_path) > -1; }); matches.forEach(function (m) { - var idx = searchPaths.indexOf(m); + const idx = searchPaths.indexOf(m); searchPaths.splice(idx, 1); }); } @@ -1153,10 +1153,10 @@ pbxProject.prototype.removeFromFrameworkSearchPaths = function (file) { }; pbxProject.prototype.addToFrameworkSearchPaths = function (file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const INHERITED = '"$(inherited)"'; + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1173,12 +1173,12 @@ pbxProject.prototype.addToFrameworkSearchPaths = function (file) { }; pbxProject.prototype.removeFromLibrarySearchPaths = function (file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS'; - var config; - var buildSettings; - var searchPaths; - var new_path = searchPathForFile(file, this); + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS'; + let config; + let buildSettings; + let searchPaths; + const new_path = searchPathForFile(file, this); for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1188,11 +1188,11 @@ pbxProject.prototype.removeFromLibrarySearchPaths = function (file) { searchPaths = buildSettings[SEARCH_PATHS]; if (searchPaths && Array.isArray(searchPaths)) { - var matches = searchPaths.filter(function (p) { + const matches = searchPaths.filter(function (p) { return p.indexOf(new_path) > -1; }); matches.forEach(function (m) { - var idx = searchPaths.indexOf(m); + const idx = searchPaths.indexOf(m); searchPaths.splice(idx, 1); }); } @@ -1200,10 +1200,10 @@ pbxProject.prototype.removeFromLibrarySearchPaths = function (file) { }; pbxProject.prototype.addToLibrarySearchPaths = function (file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const INHERITED = '"$(inherited)"'; + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1224,11 +1224,11 @@ pbxProject.prototype.addToLibrarySearchPaths = function (file) { }; pbxProject.prototype.removeFromHeaderSearchPaths = function (file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var SEARCH_PATHS = 'HEADER_SEARCH_PATHS'; - var config; - var buildSettings; - var new_path = searchPathForFile(file, this); + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const SEARCH_PATHS = 'HEADER_SEARCH_PATHS'; + let config; + let buildSettings; + const new_path = searchPathForFile(file, this); for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1236,21 +1236,21 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function (file) { if (unquote(buildSettings.PRODUCT_NAME) !== this.productName) { continue; } if (buildSettings[SEARCH_PATHS]) { - var matches = buildSettings[SEARCH_PATHS].filter(function (p) { + const matches = buildSettings[SEARCH_PATHS].filter(function (p) { return p.indexOf(new_path) > -1; }); matches.forEach(function (m) { - var idx = buildSettings[SEARCH_PATHS].indexOf(m); + const idx = buildSettings[SEARCH_PATHS].indexOf(m); buildSettings[SEARCH_PATHS].splice(idx, 1); }); } } }; pbxProject.prototype.addToHeaderSearchPaths = function (file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const INHERITED = '"$(inherited)"'; + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1270,11 +1270,11 @@ pbxProject.prototype.addToHeaderSearchPaths = function (file) { }; pbxProject.prototype.addToOtherLinkerFlags = function (flag) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var INHERITED = '"$(inherited)"'; - var OTHER_LDFLAGS = 'OTHER_LDFLAGS'; - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const INHERITED = '"$(inherited)"'; + const OTHER_LDFLAGS = 'OTHER_LDFLAGS'; + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1291,10 +1291,10 @@ pbxProject.prototype.addToOtherLinkerFlags = function (flag) { }; pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var OTHER_LDFLAGS = 'OTHER_LDFLAGS'; - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + const OTHER_LDFLAGS = 'OTHER_LDFLAGS'; + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1304,11 +1304,11 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { } if (buildSettings[OTHER_LDFLAGS]) { - var matches = buildSettings[OTHER_LDFLAGS].filter(function (p) { + const matches = buildSettings[OTHER_LDFLAGS].filter(function (p) { return p.indexOf(flag) > -1; }); matches.forEach(function (m) { - var idx = buildSettings[OTHER_LDFLAGS].indexOf(m); + const idx = buildSettings[OTHER_LDFLAGS].indexOf(m); buildSettings[OTHER_LDFLAGS].splice(idx, 1); }); } @@ -1316,9 +1316,9 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { }; pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1328,9 +1328,9 @@ pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { }; pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var config; - var buildSettings; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + let config; + let buildSettings; for (config in configurations) { buildSettings = configurations[config].buildSettings; @@ -1343,9 +1343,9 @@ pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { // a JS getter. hmmm pbxProject.prototype.__defineGetter__('productName', function () { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()); - var config; - var productName; + const configurations = nonComments(this.pbxXCBuildConfigurationSection()); + let config; + let productName; for (config in configurations) { productName = configurations[config].buildSettings.PRODUCT_NAME; @@ -1358,10 +1358,10 @@ pbxProject.prototype.__defineGetter__('productName', function () { // check if file is present pbxProject.prototype.hasFile = function (filePath) { - var files = nonComments(this.pbxFileReferenceSection()); - var file; + const files = nonComments(this.pbxFileReferenceSection()); + let file; - for (var id in files) { + for (const id in files) { file = files[id]; if (file.path === filePath || file.path === ('"' + filePath + '"')) { return file; @@ -1373,11 +1373,11 @@ pbxProject.prototype.hasFile = function (filePath) { pbxProject.prototype.addTarget = function (name, type, subfolder) { // Setup uuid and name of new target - var targetUuid = this.generateUuid(); + const targetUuid = this.generateUuid(); - var targetType = type; - var targetSubfolder = subfolder || name; - var targetName = name.trim(); + const targetType = type; + const targetSubfolder = subfolder || name; + const targetName = name.trim(); // Check type against list of allowed target types if (!targetName) { @@ -1395,7 +1395,7 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { } // Build Configuration: Create - var buildConfigurationsList = [ + const buildConfigurationsList = [ { name: 'Debug', isa: 'XCBuildConfiguration', @@ -1420,20 +1420,20 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { ]; // Build Configuration: Add - var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName + '"'); + const buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName + '"'); // Product: Create - var productName = targetName; + const productName = targetName; - var productType = producttypeForTargettype(targetType); - var productFileType = filetypeForProducttype(productType); - var productFile = this.addProductFile(productName, { group: 'Copy Files', target: targetUuid, explicitFileType: productFileType }); + const productType = producttypeForTargettype(targetType); + const productFileType = filetypeForProducttype(productType); + const productFile = this.addProductFile(productName, { group: 'Copy Files', target: targetUuid, explicitFileType: productFileType }); // Product: Add to build file list this.addToPbxBuildFileSection(productFile); // Target: Create - var target = { + const target = { uuid: targetUuid, pbxNativeTarget: { isa: 'PBXNativeTarget', @@ -1472,7 +1472,7 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { ); } else if (targetType === 'watch2_extension') { // Create CopyFiles phase in watch target (if exists) - var watch2AppTarget = this.getTarget(producttypeForTargettype('watch2_app')); + const watch2AppTarget = this.getTarget(producttypeForTargettype('watch2_app')); if (watch2AppTarget) { this.addBuildPhase( [targetName + '.appex'], @@ -1489,7 +1489,7 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { // Target: Add dependency for this target to other targets if (targetType === 'watch2_extension') { - var watch2ExtensionTarget = this.getTarget(producttypeForTargettype('watch2_app')); + const watch2ExtensionTarget = this.getTarget(producttypeForTargettype('watch2_app')); if (watch2ExtensionTarget) { this.addTargetDependency(watch2ExtensionTarget.uuid, [target.uuid]); } @@ -1503,7 +1503,7 @@ pbxProject.prototype.addTarget = function (name, type, subfolder) { // helper object creation functions function pbxBuildFileObj (file) { - var obj = Object.create(null); + const obj = Object.create(null); obj.isa = 'PBXBuildFile'; obj.fileRef = file.fileRef; @@ -1514,7 +1514,7 @@ function pbxBuildFileObj (file) { } function pbxFileReferenceObj (file) { - var fileObject = { + const fileObject = { isa: 'PBXFileReference', name: '"' + file.basename + '"', path: '"' + file.path.replace(/\\/g, '/') + '"', @@ -1529,7 +1529,7 @@ function pbxFileReferenceObj (file) { } function pbxGroupChild (file) { - var obj = Object.create(null); + const obj = Object.create(null); obj.value = file.fileRef; obj.comment = file.basename; @@ -1538,7 +1538,7 @@ function pbxGroupChild (file) { } function pbxBuildPhaseObj (file) { - var obj = Object.create(null); + const obj = Object.create(null); obj.value = file.uuid; obj.comment = longComment(file); @@ -1548,7 +1548,7 @@ function pbxBuildPhaseObj (file) { function pbxCopyFilesBuildPhaseObj (obj, folderType, subfolderPath, phaseName) { // Add additional properties for 'CopyFiles' build phase - var DESTINATION_BY_TARGETTYPE = { + const DESTINATION_BY_TARGETTYPE = { application: 'wrapper', app_extension: 'plugins', bundle: 'wrapper', @@ -1563,7 +1563,7 @@ function pbxCopyFilesBuildPhaseObj (obj, folderType, subfolderPath, phaseName) { watch_extension: 'plugins', watch2_extension: 'plugins' }; - var SUBFOLDERSPEC_BY_DESTINATION = { + const SUBFOLDERSPEC_BY_DESTINATION = { absolute_path: 0, executables: 6, frameworks: 10, @@ -1620,7 +1620,7 @@ function correctForResourcesPath (file, project) { } function correctForPath (file, project, group) { - var r_group_dir = new RegExp('^' + group + '[\\\\/]'); + const r_group_dir = new RegExp('^' + group + '[\\\\/]'); if (project.pbxGroupByName(group).path) { file.path = file.path.replace(r_group_dir, ''); } @@ -1628,9 +1628,9 @@ function correctForPath (file, project, group) { } function searchPathForFile (file, proj) { - var plugins = proj.pbxGroupByName('Plugins'); - var pluginsPath = plugins ? plugins.path : null; - var fileDir = path.dirname(file.path); + const plugins = proj.pbxGroupByName('Plugins'); + const pluginsPath = plugins ? plugins.path : null; + let fileDir = path.dirname(file.path); if (fileDir === '.') { fileDir = ''; @@ -1648,10 +1648,10 @@ function searchPathForFile (file, proj) { } function nonComments (obj) { - var keys = Object.keys(obj); - var newObj = {}; + const keys = Object.keys(obj); + const newObj = {}; - for (var i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { if (!COMMENT_KEY.test(keys[i])) { newObj[keys[i]] = obj[keys[i]]; } @@ -1665,7 +1665,7 @@ function unquote (str) { } function producttypeForTargettype (targetType) { - var PRODUCTTYPE_BY_TARGETTYPE = { + const PRODUCTTYPE_BY_TARGETTYPE = { application: 'com.apple.product-type.application', app_extension: 'com.apple.product-type.app-extension', bundle: 'com.apple.product-type.bundle', @@ -1684,7 +1684,7 @@ function producttypeForTargettype (targetType) { } function filetypeForProducttype (productType) { - var FILETYPE_BY_PRODUCTTYPE = { + const FILETYPE_BY_PRODUCTTYPE = { 'com.apple.product-type.application': '"wrapper.application"', 'com.apple.product-type.app-extension': '"wrapper.app-extension"', 'com.apple.product-type.bundle': '"wrapper.plug-in"', @@ -1704,13 +1704,13 @@ function filetypeForProducttype (productType) { pbxProject.prototype.getFirstProject = function () { // Get pbxProject container - var pbxProjectContainer = this.pbxProjectSection(); + const pbxProjectContainer = this.pbxProjectSection(); // Get first pbxProject UUID - var firstProjectUuid = Object.keys(pbxProjectContainer)[0]; + const firstProjectUuid = Object.keys(pbxProjectContainer)[0]; // Get first pbxProject - var firstProject = pbxProjectContainer[firstProjectUuid]; + const firstProject = pbxProjectContainer[firstProjectUuid]; return { uuid: firstProjectUuid, @@ -1720,10 +1720,10 @@ pbxProject.prototype.getFirstProject = function () { pbxProject.prototype.getFirstTarget = function () { // Get first target's UUID - var firstTargetUuid = this.getFirstProject().firstProject.targets[0].value; + const firstTargetUuid = this.getFirstProject().firstProject.targets[0].value; // Get first pbxNativeTarget - var firstTarget = this.pbxNativeTargetSection()[firstTargetUuid]; + const firstTarget = this.pbxNativeTargetSection()[firstTargetUuid]; return { uuid: firstTargetUuid, @@ -1733,14 +1733,14 @@ pbxProject.prototype.getFirstTarget = function () { pbxProject.prototype.getTarget = function (productType) { // Find target by product type - var targets = this.getFirstProject().firstProject.targets; - var nativeTargets = this.pbxNativeTargetSection(); - for (var i = 0; i < targets.length; i++) { - var target = targets[i]; - var targetUuid = target.value; + const targets = this.getFirstProject().firstProject.targets; + const nativeTargets = this.pbxNativeTargetSection(); + for (let i = 0; i < targets.length; i++) { + const target = targets[i]; + const targetUuid = target.value; if (nativeTargets[targetUuid].productType === '"' + productType + '"') { // Get pbxNativeTarget - var nativeTarget = this.pbxNativeTargetSection()[targetUuid]; + const nativeTarget = this.pbxNativeTargetSection()[targetUuid]; return { uuid: targetUuid, target: nativeTarget @@ -1754,11 +1754,11 @@ pbxProject.prototype.getTarget = function (productType) { /** * NEW ***/ pbxProject.prototype.addToPbxGroupType = function (file, groupKey, groupType) { - var group = this.getPBXGroupByKeyAndType(groupKey, groupType); + const group = this.getPBXGroupByKeyAndType(groupKey, groupType); if (group && group.children !== undefined) { if (typeof file === 'string') { // Group Key - var childGroup = { + const childGroup = { value: file }; if (this.getPBXGroupByKey(file)) { @@ -1785,20 +1785,20 @@ pbxProject.prototype.addToPbxGroup = function (file, groupKey) { pbxProject.prototype.pbxCreateGroupWithType = function (name, pathName, groupType) { // Create object - var model = { + const model = { isa: '"' + groupType + '"', children: [], name: name, sourceTree: '""' }; if (pathName) model.path = pathName; - var key = this.generateUuid(); + const key = this.generateUuid(); // Create comment - var commendId = key + '_comment'; + const commendId = key + '_comment'; // add obj and commentObj to groups; - var groups = this.hash.project.objects[groupType]; + let groups = this.hash.project.objects[groupType]; if (!groups) { groups = this.hash.project.objects[groupType] = {}; } @@ -1817,10 +1817,10 @@ pbxProject.prototype.pbxCreateGroup = function (name, pathName) { }; pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, groupType) { - var group = this.getPBXGroupByKeyAndType(groupKey, groupType); + const group = this.getPBXGroupByKeyAndType(groupKey, groupType); if (group) { - var groupChildren = group.children; - for (var i in groupChildren) { + const groupChildren = group.children; + for (const i in groupChildren) { if (pbxGroupChild(file).value === groupChildren[i].value && pbxGroupChild(file).comment === groupChildren[i].comment) { groupChildren.splice(i, 1); @@ -1851,14 +1851,14 @@ pbxProject.prototype.getPBXVariantGroupByKey = function (key) { }; pbxProject.prototype.findPBXGroupKeyAndType = function (criteria, groupType) { - var groups = this.hash.project.objects[groupType]; - var target; + const groups = this.hash.project.objects[groupType]; + let target; - for (var key in groups) { + for (const key in groups) { // only look for comments if (COMMENT_KEY.test(key)) continue; - var group = groups[key]; + const group = groups[key]; if (criteria && criteria.path && criteria.name) { if (criteria.path === group.path && criteria.name === group.name) { target = key; @@ -1889,12 +1889,12 @@ pbxProject.prototype.findPBXVariantGroupKey = function (criteria) { }; pbxProject.prototype.addLocalizationVariantGroup = function (name) { - var groupKey = this.pbxCreateVariantGroup(name); + const groupKey = this.pbxCreateVariantGroup(name); - var resourceGroupKey = this.findPBXGroupKey({ name: 'Resources' }); + const resourceGroupKey = this.findPBXGroupKey({ name: 'Resources' }); this.addToPbxGroup(groupKey, resourceGroupKey); - var localizationVariantGroup = { + const localizationVariantGroup = { uuid: this.generateUuid(), fileRef: groupKey, basename: name @@ -1915,9 +1915,9 @@ pbxProject.prototype.addKnownRegion = function (name) { }; pbxProject.prototype.removeKnownRegion = function (name) { - var regions = this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions; + const regions = this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions; if (regions) { - for (var i = 0; i < regions.length; i++) { + for (let i = 0; i < regions.length; i++) { if (regions[i] === name) { regions.splice(i, 1); break; @@ -1928,9 +1928,9 @@ pbxProject.prototype.removeKnownRegion = function (name) { }; pbxProject.prototype.hasKnownRegion = function (name) { - var regions = this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions; + const regions = this.pbxProjectSection()[this.getFirstProject().uuid].knownRegions; if (regions) { - for (var i in regions) { + for (const i in regions) { if (regions[i] === name) { return true; } @@ -1944,7 +1944,7 @@ pbxProject.prototype.getPBXObject = function (name) { }; pbxProject.prototype.addFile = function (path, group, opt) { - var file = new pbxFile(path, opt); + const file = new pbxFile(path, opt); // null is better for early errors if (this.hasFile(file.path)) return null; @@ -1963,7 +1963,7 @@ pbxProject.prototype.addFile = function (path, group, opt) { }; pbxProject.prototype.removeFile = function (path, group, opt) { - var file = new pbxFile(path, opt); + const file = new pbxFile(path, opt); this.removeFromPbxFileReferenceSection(file); // PBXFileReference @@ -1977,11 +1977,11 @@ pbxProject.prototype.removeFile = function (path, group, opt) { }; pbxProject.prototype.getBuildProperty = function (prop, build) { - var target; - var configs = this.pbxXCBuildConfigurationSection(); - for (var configName in configs) { + let target; + const configs = this.pbxXCBuildConfigurationSection(); + for (const configName in configs) { if (!COMMENT_KEY.test(configName)) { - var config = configs[configName]; + const config = configs[configName]; if ((build && config.name === build) || (build === undefined)) { if (config.buildSettings[prop] !== undefined) { target = config.buildSettings[prop]; @@ -1993,11 +1993,11 @@ pbxProject.prototype.getBuildProperty = function (prop, build) { }; pbxProject.prototype.getBuildConfigByName = function (name) { - var target = {}; - var configs = this.pbxXCBuildConfigurationSection(); - for (var configName in configs) { + const target = {}; + const configs = this.pbxXCBuildConfigurationSection(); + for (const configName in configs) { if (!COMMENT_KEY.test(configName)) { - var config = configs[configName]; + const config = configs[configName]; if (config.name === name) { target[configName] = config; } @@ -2014,7 +2014,7 @@ pbxProject.prototype.addDataModelDocument = function (filePath, group, opt) { group = this.findPBXGroupKey({ name: group }); } - var file = new pbxFile(filePath, opt); + const file = new pbxFile(filePath, opt); if (!file || this.hasFile(file.path)) return null; @@ -2030,18 +2030,18 @@ pbxProject.prototype.addDataModelDocument = function (filePath, group, opt) { this.addToPbxSourcesBuildPhase(file); file.models = []; - var currentVersionName; - var modelFiles = fs.readdirSync(file.path); - for (var index in modelFiles) { - var modelFileName = modelFiles[index]; - var modelFilePath = path.join(filePath, modelFileName); + let currentVersionName; + const modelFiles = fs.readdirSync(file.path); + for (const index in modelFiles) { + const modelFileName = modelFiles[index]; + const modelFilePath = path.join(filePath, modelFileName); if (modelFileName === '.xccurrentversion') { currentVersionName = plist.readFileSync(modelFilePath)._XCCurrentVersionName; continue; } - var modelFile = new pbxFile(modelFilePath); + const modelFile = new pbxFile(modelFilePath); modelFile.fileRef = this.generateUuid(); this.addToPbxFileReferenceSection(modelFile); @@ -2063,7 +2063,7 @@ pbxProject.prototype.addDataModelDocument = function (filePath, group, opt) { }; pbxProject.prototype.addTargetAttribute = function (prop, value, target) { - var attributes = this.getFirstProject().firstProject.attributes; + const attributes = this.getFirstProject().firstProject.attributes; if (attributes.TargetAttributes === undefined) { attributes.TargetAttributes = {}; } @@ -2075,7 +2075,7 @@ pbxProject.prototype.addTargetAttribute = function (prop, value, target) { }; pbxProject.prototype.removeTargetAttribute = function (prop, target) { - var attributes = this.getFirstProject().firstProject.attributes; + const attributes = this.getFirstProject().firstProject.attributes; target = target || this.getFirstTarget(); if (attributes.TargetAttributes && attributes.TargetAttributes[target.uuid]) { diff --git a/lib/pbxWriter.js b/lib/pbxWriter.js index a6d918a..b3e30e3 100644 --- a/lib/pbxWriter.js +++ b/lib/pbxWriter.js @@ -15,11 +15,11 @@ under the License. */ -var util = require('util'); -var f = util.format; -var INDENT = '\t'; -var COMMENT_KEY = /_comment$/; -var EventEmitter = require('events').EventEmitter; +const util = require('util'); +const f = util.format; +const INDENT = '\t'; +const COMMENT_KEY = /_comment$/; +const EventEmitter = require('events').EventEmitter; // indentation function i (x) { @@ -27,7 +27,7 @@ function i (x) { } function comment (key, parent) { - var text = parent[key + '_comment']; + const text = parent[key + '_comment']; if (text) { return text; } else { return null; } } @@ -58,7 +58,7 @@ function pbxWriter (contents, options) { util.inherits(pbxWriter, EventEmitter); pbxWriter.prototype.write = function (str) { - var fmt = f.apply(null, arguments); + const fmt = f.apply(null, arguments); if (this.sync) { this.buffer += f('%s%s', i(this.indentLevel), fmt); @@ -68,7 +68,7 @@ pbxWriter.prototype.write = function (str) { }; pbxWriter.prototype.writeFlush = function (str) { - var oldIndent = this.indentLevel; + const oldIndent = this.indentLevel; this.indentLevel = 0; @@ -94,10 +94,10 @@ pbxWriter.prototype.writeHeadComment = function () { }; pbxWriter.prototype.writeProject = function () { - var proj = this.contents.project; - var key; - var cmt; - var obj; + const proj = this.contents.project; + let key; + let cmt; + let obj; this.write('{\n'); @@ -141,9 +141,9 @@ pbxWriter.prototype.writeProject = function () { }; pbxWriter.prototype.writeObject = function (object) { - var key; - var obj; - var cmt; + let key; + let obj; + let cmt; for (key in object) { if (COMMENT_KEY.test(key)) continue; @@ -174,8 +174,8 @@ pbxWriter.prototype.writeObject = function (object) { }; pbxWriter.prototype.writeObjectsSections = function (objects) { - var key; - var obj; + let key; + let obj; for (key in objects) { this.writeFlush('\n'); @@ -193,8 +193,8 @@ pbxWriter.prototype.writeObjectsSections = function (objects) { }; pbxWriter.prototype.writeArray = function (arr, name) { - var i; - var entry; + let i; + let entry; this.write('%s = (\n', name); this.indentLevel++; @@ -230,9 +230,9 @@ pbxWriter.prototype.writeSectionComment = function (name, begin) { }; pbxWriter.prototype.writeSection = function (section) { - var key; - var obj; - var cmt; + let key; + let obj; + let cmt; // section should only contain objects for (key in section) { @@ -261,13 +261,13 @@ pbxWriter.prototype.writeSection = function (section) { }; pbxWriter.prototype.writeInlineObject = function (n, d, r) { - var output = []; - var self = this; + const output = []; + const self = this; - var inlineObjectHelper = function (name, desc, ref) { - var key; - var cmt; - var obj; + const inlineObjectHelper = function (name, desc, ref) { + let key; + let cmt; + let obj; if (desc) { output.push(f('%s /* %s */ = {', name, desc)); @@ -284,7 +284,7 @@ pbxWriter.prototype.writeInlineObject = function (n, d, r) { if (isArray(obj)) { output.push(f('%s = (', key)); - for (var i = 0; i < obj.length; i++) { + for (let i = 0; i < obj.length; i++) { output.push(f('%s, ', obj[i])); }