plist 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +1 -0
- package/History.md +13 -2
- package/README.md +55 -4
- package/lib/parse.js +19 -1
- package/package.json +6 -6
package/.travis.yml
CHANGED
package/History.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
2.0.1 / 2016-08-16
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* [[`de136c8388`](https://github.com/TooTallNate/plist/commit/de136c8388)] - bad npm release… (Nathan Rajlich)
|
|
5
|
+
|
|
1
6
|
2.0.0 / 2016-08-16
|
|
2
7
|
==================
|
|
3
8
|
|
|
4
|
-
* [[`
|
|
9
|
+
* [[`90deef5d43`](https://github.com/TooTallNate/plist/commit/90deef5d43)] - remove deprecated functions (Nathan Rajlich)
|
|
10
|
+
* [[`d475cd8ce9`](https://github.com/TooTallNate/plist/commit/d475cd8ce9)] - Added travis ci support for node 6 (Amila Welihinda)
|
|
11
|
+
* [[`04c8ee7646`](https://github.com/TooTallNate/plist/commit/04c8ee7646)] - update dependencies (Mitchell Hentges)
|
|
5
12
|
* [[`97c02b3f05`](https://github.com/TooTallNate/plist/commit/97c02b3f05)] - **travis**: add `sudo: false` and test more node versions (Nathan Rajlich)
|
|
6
|
-
* [[`
|
|
13
|
+
* [[`54c821ec29`](https://github.com/TooTallNate/plist/commit/54c821ec29)] - #71 - fixed and added test (Andrew Goldis)
|
|
14
|
+
* [[`4afb7c5079`](https://github.com/TooTallNate/plist/commit/4afb7c5079)] - fix `Cannot read property 'nodeValue' of undefined exception` that is thrown when a `<key></key>` construct appears in plist (Chris Kinsman)
|
|
15
|
+
* [[`f360d7d685`](https://github.com/TooTallNate/plist/commit/f360d7d685)] - #66 - fixed empty keys and added tests (Andrew Goldis)
|
|
16
|
+
* [[`421c7f26e9`](https://github.com/TooTallNate/plist/commit/421c7f26e9)] - #66 - fixed empty key (Andrew Goldis)
|
|
17
|
+
* [[`a88aa4dca7`](https://github.com/TooTallNate/plist/commit/a88aa4dca7)] - add verbose examples (mrzmyr)
|
|
7
18
|
|
|
8
19
|
1.2.0 / 2015-11-10
|
|
9
20
|
==================
|
package/README.md
CHANGED
|
@@ -69,8 +69,34 @@ Parsing a plist from string payload:
|
|
|
69
69
|
``` javascript
|
|
70
70
|
var plist = require('plist');
|
|
71
71
|
|
|
72
|
-
var
|
|
73
|
-
|
|
72
|
+
var xml =
|
|
73
|
+
'<?xml version="1.0" encoding="UTF-8"?>' +
|
|
74
|
+
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' +
|
|
75
|
+
'<plist version="1.0">' +
|
|
76
|
+
'<key>metadata</key>' +
|
|
77
|
+
'<dict>' +
|
|
78
|
+
'<key>bundle-identifier</key>' +
|
|
79
|
+
'<string>com.company.app</string>' +
|
|
80
|
+
'<key>bundle-version</key>' +
|
|
81
|
+
'<string>0.1.1</string>' +
|
|
82
|
+
'<key>kind</key>' +
|
|
83
|
+
'<string>software</string>' +
|
|
84
|
+
'<key>title</key>' +
|
|
85
|
+
'<string>AppName</string>' +
|
|
86
|
+
'</dict>' +
|
|
87
|
+
'</plist>';
|
|
88
|
+
|
|
89
|
+
console.log(plist.parse(xml));
|
|
90
|
+
|
|
91
|
+
// [
|
|
92
|
+
// "metadata",
|
|
93
|
+
// {
|
|
94
|
+
// "bundle-identifier": "com.company.app",
|
|
95
|
+
// "bundle-version": "0.1.1",
|
|
96
|
+
// "kind": "software",
|
|
97
|
+
// "title": "AppName"
|
|
98
|
+
// }
|
|
99
|
+
// ]
|
|
74
100
|
```
|
|
75
101
|
|
|
76
102
|
### Building
|
|
@@ -81,10 +107,35 @@ that complies with the plist DTD:
|
|
|
81
107
|
``` javascript
|
|
82
108
|
var plist = require('plist');
|
|
83
109
|
|
|
84
|
-
|
|
110
|
+
var json = [
|
|
111
|
+
"metadata",
|
|
112
|
+
{
|
|
113
|
+
"bundle-identifier": "com.company.app",
|
|
114
|
+
"bundle-version": "0.1.1",
|
|
115
|
+
"kind": "software",
|
|
116
|
+
"title": "AppName"
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
console.log(plist.build(json));
|
|
121
|
+
|
|
122
|
+
// <?xml version="1.0" encoding="UTF-8"?>
|
|
123
|
+
// <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
124
|
+
// <plist version="1.0">
|
|
125
|
+
// <key>metadata</key>
|
|
126
|
+
// <dict>
|
|
127
|
+
// <key>bundle-identifier</key>
|
|
128
|
+
// <string>com.company.app</string>
|
|
129
|
+
// <key>bundle-version</key>
|
|
130
|
+
// <string>0.1.1</string>
|
|
131
|
+
// <key>kind</key>
|
|
132
|
+
// <string>software</string>
|
|
133
|
+
// <key>title</key>
|
|
134
|
+
// <string>AppName</string>
|
|
135
|
+
// </dict>
|
|
136
|
+
// </plist>
|
|
85
137
|
```
|
|
86
138
|
|
|
87
|
-
|
|
88
139
|
## License
|
|
89
140
|
|
|
90
141
|
(The MIT License)
|
package/lib/parse.js
CHANGED
|
@@ -25,6 +25,23 @@ function shouldIgnoreNode (node) {
|
|
|
25
25
|
|| node.nodeType === 4; // cdata
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Check if the node is empty. Some plist file has such node:
|
|
30
|
+
* <key />
|
|
31
|
+
* this node shoud be ignored.
|
|
32
|
+
*
|
|
33
|
+
* @see https://github.com/TooTallNate/plist.js/issues/66
|
|
34
|
+
* @param {Element} node
|
|
35
|
+
* @returns {Boolean}
|
|
36
|
+
* @api private
|
|
37
|
+
*/
|
|
38
|
+
function isEmptyNode(node){
|
|
39
|
+
if(!node.childNodes || node.childNodes.length === 0) {
|
|
40
|
+
return true;
|
|
41
|
+
} else {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
28
45
|
|
|
29
46
|
/**
|
|
30
47
|
* Parses a Plist XML string. Returns an Object.
|
|
@@ -103,14 +120,15 @@ function parsePlistXML (node) {
|
|
|
103
120
|
// TODO: what should we do with text types? (CDATA sections)
|
|
104
121
|
|
|
105
122
|
} else if (node.nodeName === 'key') {
|
|
123
|
+
if(isEmptyNode(node)) return null;
|
|
106
124
|
res = '';
|
|
107
125
|
if(node.childNodes[0]) {
|
|
108
126
|
res = node.childNodes[0].nodeValue;
|
|
109
127
|
}
|
|
110
128
|
return res;
|
|
111
|
-
|
|
112
129
|
} else if (node.nodeName === 'string') {
|
|
113
130
|
res = '';
|
|
131
|
+
if(isEmptyNode(node)) return null;
|
|
114
132
|
for (d=0; d < node.childNodes.length; d++) {
|
|
115
133
|
res += node.childNodes[d].nodeValue;
|
|
116
134
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plist",
|
|
3
3
|
"description": "Mac OS X Plist parser/builder for Node.js and browsers",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"author": "Nathan Rajlich <nathan@tootallnate.net>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Hans Huebner <hans.huebner@gmail.com>",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
],
|
|
26
26
|
"main": "index.js",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"base64-js": "
|
|
29
|
-
"xmlbuilder": "
|
|
28
|
+
"base64-js": "1.1.2",
|
|
29
|
+
"xmlbuilder": "8.2.2",
|
|
30
30
|
"xmldom": "0.1.x"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"browserify": "
|
|
34
|
-
"mocha": "2.
|
|
33
|
+
"browserify": "13.0.1",
|
|
34
|
+
"mocha": "2.4.5",
|
|
35
35
|
"multiline": "1.0.2",
|
|
36
|
-
"zuul": "3.
|
|
36
|
+
"zuul": "3.10.1"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test": "make test"
|