Comparing version 1.0.0 to 1.1.0
@@ -86,3 +86,3 @@ /** | ||
function unquoted(text){ | ||
return text.replace (/(^")|("$)/g, '') | ||
return text == null ? '' : text.replace (/(^")|("$)/g, '') | ||
} | ||
@@ -102,7 +102,8 @@ | ||
function defaultExtension(fileRef) { | ||
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; | ||
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)] === filetype ) | ||
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) ) | ||
return extension; | ||
@@ -109,0 +110,0 @@ } |
@@ -52,6 +52,14 @@ /** | ||
function pbxWriter(contents) { | ||
function pbxWriter(contents, options) { | ||
if (!options) { | ||
options = {} | ||
} | ||
if (options.omitEmptyValues === undefined) { | ||
options.omitEmptyValues = false | ||
} | ||
this.contents = contents; | ||
this.sync = false; | ||
this.indentLevel = 0; | ||
this.omitEmptyValues = options.omitEmptyValues | ||
} | ||
@@ -127,2 +135,4 @@ | ||
this.write("};\n"); | ||
} else if (this.omitEmptyValues && (obj === undefined || obj === null)) { | ||
continue; | ||
} else if (cmt) { | ||
@@ -161,3 +171,5 @@ this.write("%s = %s /* %s */;\n", key, obj, cmt) | ||
} else { | ||
if (cmt) { | ||
if (this.omitEmptyValues && (obj === undefined || obj === null)) { | ||
continue; | ||
} else if (cmt) { | ||
this.write("%s = %s /* %s */;\n", key, obj, cmt) | ||
@@ -208,3 +220,3 @@ } else { | ||
this.indentLevel++; | ||
this.writeObject(entry); | ||
@@ -262,2 +274,3 @@ | ||
var output = []; | ||
var self = this | ||
@@ -281,3 +294,3 @@ var inlineObjectHelper = function (name, desc, ref) { | ||
output.push(f("%s = (", key)); | ||
for (var i=0; i < obj.length; i++) { | ||
@@ -290,2 +303,4 @@ output.push(f("%s, ", obj[i])) | ||
inlineObjectHelper(key, cmt, obj) | ||
} else if (self.omitEmptyValues && (obj === undefined || obj === null)) { | ||
continue; | ||
} else if (cmt) { | ||
@@ -292,0 +307,0 @@ output.push(f("%s = %s /* %s */; ", key, obj, cmt)) |
@@ -5,3 +5,3 @@ { | ||
"description": "parser for xcodeproj/project.pbxproj files", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
@@ -15,10 +15,11 @@ "repository": { | ||
"dependencies": { | ||
"pegjs": "^0.10.0", | ||
"simple-plist": "^0.2.1", | ||
"uuid": "3.0.1" | ||
"uuid": "^3.3.2" | ||
}, | ||
"devDependencies": { | ||
"nodeunit": "^0.11.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" | ||
@@ -48,5 +49,3 @@ }, | ||
} | ||
] | ||
} |
@@ -22,25 +22,32 @@ <!-- | ||
# node-xcode | ||
# cordova-node-xcode | ||
> parser/toolkit for xcodeproj project files | ||
[![NPM](https://nodei.co/npm/xcode.png?compact=true)](https://nodei.co/npm/xcode/) | ||
[![Build Status](https://travis-ci.org/apache/cordova-node-xcode.svg?branch=master)](https://travis-ci.org/apache/cordova-node-xcode) | ||
Parser utility for xcodeproj project files | ||
Allows you to edit xcodeproject files and write them back out. | ||
based on donated code from [alunny / node-xcode](https://github.com/alunny/node-xcode) | ||
## Example | ||
// API is a bit wonky right now | ||
var xcode = require('xcode'), | ||
fs = require('fs'), | ||
projectPath = 'myproject.xcodeproj/project.pbxproj', | ||
myProj = xcode.project(projectPath); | ||
```js | ||
// API is a bit wonky right now | ||
var xcode = require('xcode'), | ||
fs = require('fs'), | ||
projectPath = 'myproject.xcodeproj/project.pbxproj', | ||
myProj = xcode.project(projectPath); | ||
// parsing is async, in a different process | ||
myProj.parse(function (err) { | ||
myProj.addHeaderFile('foo.h'); | ||
myProj.addSourceFile('foo.m'); | ||
myProj.addFramework('FooKit.framework'); | ||
fs.writeFileSync(projectPath, myProj.writeSync()); | ||
console.log('new project written'); | ||
}); | ||
// parsing is async, in a different process | ||
myProj.parse(function (err) { | ||
myProj.addHeaderFile('foo.h'); | ||
myProj.addSourceFile('foo.m'); | ||
myProj.addFramework('FooKit.framework'); | ||
fs.writeFileSync(projectPath, myProj.writeSync()); | ||
console.log('new project written'); | ||
}); | ||
``` | ||
@@ -51,3 +58,3 @@ ## Working on the parser | ||
`lib/parser/pbxproj.pegjs`. You can test it online with the PEGjs online thingy | ||
at http://pegjs.majda.cz/online - I have had some mixed results though. | ||
at https://pegjs.org/online - I have had some mixed results though. | ||
@@ -59,5 +66,6 @@ Tests under the `test/parser` directory will compile the parser from the | ||
./node_modules/.bin/pegjs lib/parser/pbxproj.pegjs | ||
npm run pegjs | ||
(easier if `./node_modules/.bin` is in your path) | ||
(and be sure to restore the Apache license notice in | ||
`lib/parser/pbxproj.js` before committing) | ||
@@ -64,0 +72,0 @@ ## License |
@@ -23,2 +23,13 @@ <!-- | ||
### 1.1.0 (Dec 19, 2018) | ||
* feat: omit objects with empty values ([#24](https://github.com/apache/cordova-node-xcode/pull/24)) | ||
* Resolve issue with `pbxFile` extension ([#31](https://github.com/apache/cordova-node-xcode/pull/31)) | ||
* uuid@3 update ([#40](https://github.com/apache/cordova-node-xcode/pull/40)) | ||
* move `pegjs` to `devDependencies` in `package.json` ([#10](https://github.com/apache/cordova-node-xcode/pull/10)) | ||
* Fixed bug where comment is not removed on removing embedded frameworks. ([#5](https://github.com/apache/cordova-node-xcode/pull/5)) | ||
* Remove trailing whitespace from `lib/pbxWriter.js` ([#35](https://github.com/apache/cordova-node-xcode/pull/35)) | ||
* docs(readme): highlight code example ([#25](https://github.com/apache/cordova-node-xcode/pull/25)) | ||
* update invalid link to PEGjs in `README.md` ([#8](https://github.com/apache/cordova-node-xcode/pull/8)) | ||
* [CB-14145](https://issues.apache.org/jira/browse/CB-14145) explicit nodeunit@^0.11.3 update in `devDependencies` ([#10](https://github.com/apache/cordova-node-xcode/pull/10)) | ||
### 1.0.0 (Oct 4, 2017) | ||
@@ -25,0 +36,0 @@ * Bump version to 1.0.0 to represent stability and follow semver more closely |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
153521
2
3884
72
2
+ Addeduuid@3.4.0(transitive)
- Removedpegjs@^0.10.0
- Removedpegjs@0.10.0(transitive)
- Removeduuid@3.0.1(transitive)
Updateduuid@^3.3.2