mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
CB-9835 Downgrade properties-parser
to prevent failures in Node < 4.x
This commit is contained in:
parent
12c282ce5c
commit
1151856d38
5
node_modules/properties-parser/README.markdown
generated
vendored
5
node_modules/properties-parser/README.markdown
generated
vendored
@ -22,10 +22,7 @@ Currently works with any version of node.js.
|
||||
|
||||
- `parse(text)`: Parses `text` into key-value pairs. Returns an object containing the key-value pairs.
|
||||
- `read(path[, callback])`: Opens the file specified by `path` and calls `parse` on its content. If the optional `callback` parameter is provided, the result is then passed to it as the second parameter. If an error occurs, the error object is passed to `callback` as the first parameter. If `callback` is not provided, the file specified by `path` is synchronously read and calls `parse` on its contents. The resulting object is immediately returned.
|
||||
- `createEditor([path][, options][, callback]])`: If neither `path` or `callback` are provided an empty editor object is returned synchronously. If only `path` is provided, the file specified by `path` is synchronously read and parsed. An editor object with the results in then immediately returned. If both `path` and `callback` are provided, the file specified by `path` is read and parsed asynchronously. An editor object with the results are then passed to `callback` as the second parameters. If an error occurs, the error object is passed to `callback` as the first parameter. The following options are supported:
|
||||
- `options.separator`: The character used to separate key/values. Defaults to "=".
|
||||
- `options.path`: Treated the same way as the optional `path` argument. If both are provided the arguement wins.
|
||||
- `options.callback`: Treated the same way as the optional `callback` parameter. If both are provided the arguement wins.
|
||||
- `createEditor([path[, callback]])`: If neither `path` or `callback` are provided an empty editor object is returned synchronously. If only `path` is provided, the file specified by `path` is synchronously read and parsed. An editor object with the results in then immediately returned. If both `path` and `callback` are provided, the file specified by `path` is read and parsed asynchronously. An editor object with the results are then passed to `callback` as the second parameters. If an error occurs, the error object is passed to `callback` as the first parameter.
|
||||
- `Editor`: The editor object is returned by `createEditor`. Has the following API:
|
||||
- `get(key)`: Returns the value currently associated with `key`.
|
||||
- `set(key, [value[, comment]])`: Associates `key` with `value`. An optional comment can be provided. If `value` is not specified or is `null`, then `key` is unset.
|
||||
|
86
node_modules/properties-parser/index.js
generated
vendored
86
node_modules/properties-parser/index.js
generated
vendored
@ -219,42 +219,8 @@ function isNewLineRange(range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function escapeMaker(escapes) {
|
||||
return function escapeKey(key) {
|
||||
var zeros = [ "", "0", "00", "000" ];
|
||||
var buf = [];
|
||||
|
||||
for(var i = 0; i < key.length; i++) {
|
||||
var chr = key.charAt(i);
|
||||
|
||||
if(escapes[chr]) { buf.push(escapes[chr]); continue; }
|
||||
|
||||
var code = chr.codePointAt(0);
|
||||
|
||||
if(code <= 0x7F) { buf.push(chr); continue; }
|
||||
|
||||
var hex = code.toString(16);
|
||||
|
||||
buf.push("\\u");
|
||||
buf.push(zeros[4 - hex.length]);
|
||||
buf.push(hex);
|
||||
}
|
||||
|
||||
return buf.join("");
|
||||
};
|
||||
}
|
||||
|
||||
var escapeKey = escapeMaker({ " ": "\\ ", "\n": "\\n", ":": "\\:", "=": "\\=" });
|
||||
var escapeVal = escapeMaker({ "\n": "\\n" });
|
||||
|
||||
function Editor(text, options) {
|
||||
if (typeof text === 'object') {
|
||||
options = text;
|
||||
text = null;
|
||||
}
|
||||
function Editor(text, path) {
|
||||
text = text || "";
|
||||
var path = options.path;
|
||||
var separator = options.separator || '=';
|
||||
|
||||
var ranges = stringToRanges(text);
|
||||
var obj = rangesToObject(ranges, text);
|
||||
@ -280,15 +246,10 @@ function Editor(text, options) {
|
||||
if(val == null) { this.unset(key); return; }
|
||||
|
||||
obj[key] = val;
|
||||
var escapedKey = escapeKey(key);
|
||||
var escapedVal = escapeVal(val);
|
||||
|
||||
var range = keyRange[key];
|
||||
if(!range) {
|
||||
keyRange[key] = range = {
|
||||
type: "literal",
|
||||
text: escapedKey + separator + escapedVal
|
||||
};
|
||||
keyRange[key] = range = { type: "literal", text: key + "=" + val };
|
||||
|
||||
var prevRange = ranges[ranges.length - 1];
|
||||
if(prevRange != null && !isNewLineRange(prevRange)) {
|
||||
@ -303,10 +264,10 @@ function Editor(text, options) {
|
||||
}
|
||||
|
||||
if(range.type === "literal") {
|
||||
range.text = escapedKey + separator + escapedVal;
|
||||
range.text = key + "=" + val;
|
||||
if(range.comment != null) { range.text = range.comment + range.text; }
|
||||
} else if(range.type === "key-value") {
|
||||
range.children[2] = { type: "literal", text: escapedVal };
|
||||
range.children[2] = { type: "literal", text: val };
|
||||
} else {
|
||||
throw "Unknown node type: " + range.type;
|
||||
}
|
||||
@ -356,48 +317,21 @@ function Editor(text, options) {
|
||||
}
|
||||
newPath = newPath || path;
|
||||
|
||||
if(!newPath) {
|
||||
if (callback) {
|
||||
return callback("Unknown path");
|
||||
}
|
||||
throw new Error("Unknown path");
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
fs.writeFile(newPath, this.toString(), callback);
|
||||
} else {
|
||||
fs.writeFileSync(newPath, this.toString());
|
||||
}
|
||||
if(!newPath) { callback("Unknown path"); }
|
||||
|
||||
fs.writeFile(newPath, this.toString(), callback || function() {});
|
||||
};
|
||||
}
|
||||
function createEditor(/*path, options, callback*/) {
|
||||
var path, options, callback;
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
for (var i = 0; i < args.length; i ++) {
|
||||
var arg = args[i];
|
||||
if (!path && typeof arg === 'string') {
|
||||
path = arg;
|
||||
} else if (!options && typeof arg === 'object') {
|
||||
options = arg;
|
||||
} else if (!callback && typeof arg === 'function') {
|
||||
callback = arg;
|
||||
}
|
||||
}
|
||||
options = options || {};
|
||||
path = path || options.path;
|
||||
callback = callback || options.callback;
|
||||
options.path = path;
|
||||
function createEditor(path, callback) {
|
||||
if(!path) { return new Editor(); }
|
||||
|
||||
if(!path) { return new Editor(options); }
|
||||
|
||||
if(!callback) { return new Editor(fs.readFileSync(path).toString(), options); }
|
||||
if(!callback) { return new Editor(fs.readFileSync(path).toString(), path); }
|
||||
|
||||
return fs.readFile(path, function(err, text) {
|
||||
if(err) { return callback(err, null); }
|
||||
|
||||
text = text.toString();
|
||||
return callback(null, new Editor(text, options));
|
||||
return callback(null, new Editor(text, path));
|
||||
});
|
||||
}
|
||||
|
||||
|
34
node_modules/properties-parser/package.json
generated
vendored
34
node_modules/properties-parser/package.json
generated
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "properties-parser",
|
||||
"version": "0.3.0",
|
||||
"version": "0.2.3",
|
||||
"description": "A parser for .properties files written in javascript",
|
||||
"keywords": [
|
||||
"parser",
|
||||
@ -12,8 +12,9 @@
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "xavi",
|
||||
"email": "xavi.rmz@gmail.com"
|
||||
"name": "Xavi",
|
||||
"email": "xavi.rmz@gmail.com",
|
||||
"url": "http://xavi.co"
|
||||
}
|
||||
],
|
||||
"main": "./index.js",
|
||||
@ -21,30 +22,17 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/xavi-/node-properties-parser.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.3.1"
|
||||
},
|
||||
"gitHead": "d9f75e462c3da0e6eb33261e578e040994ff50c9",
|
||||
"readme": "# node-properties-parser\n\nA parser for [.properties](http://en.wikipedia.org/wiki/.properties) files written in javascript. Properties files store key-value pairs. They are typically used for configuration and internationalization in Java applications as well as in Actionscript projects. Here's an example of the format:\n\n\t# You are reading the \".properties\" entry.\n\t! The exclamation mark can also mark text as comments.\n\twebsite = http://en.wikipedia.org/\n\tlanguage = English\n\t# The backslash below tells the application to continue reading\n\t# the value onto the next line.\n\tmessage = Welcome to \\\n\t Wikipedia!\n\t# Add spaces to the key\n\tkey\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n\t# Unicode\n\ttab : \\u0009\n*(taken from [Wikipedia](http://en.wikipedia.org/wiki/.properties#Format))*\n\nCurrently works with any version of node.js.\n\n## The API\n\n- `parse(text)`: Parses `text` into key-value pairs. Returns an object containing the key-value pairs.\n- `read(path[, callback])`: Opens the file specified by `path` and calls `parse` on its content. If the optional `callback` parameter is provided, the result is then passed to it as the second parameter. If an error occurs, the error object is passed to `callback` as the first parameter. If `callback` is not provided, the file specified by `path` is synchronously read and calls `parse` on its contents. The resulting object is immediately returned.\n- `createEditor([path[, callback]])`: If neither `path` or `callback` are provided an empty editor object is returned synchronously. If only `path` is provided, the file specified by `path` is synchronously read and parsed. An editor object with the results in then immediately returned. If both `path` and `callback` are provided, the file specified by `path` is read and parsed asynchronously. An editor object with the results are then passed to `callback` as the second parameters. If an error occurs, the error object is passed to `callback` as the first parameter.\n- `Editor`: The editor object is returned by `createEditor`. Has the following API:\n\t- `get(key)`: Returns the value currently associated with `key`.\n\t- `set(key, [value[, comment]])`: Associates `key` with `value`. An optional comment can be provided. If `value` is not specified or is `null`, then `key` is unset.\n\t- `unset(key)`: Unsets the specified `key`.\n\t- `save([path][, callback]])`: Writes the current contents of this editor object to a file specified by `path`. If `path` is not provided, then it'll be defaulted to the `path` value passed to `createEditor`. The `callback` parameter is called when the file has been written to disk.\n\t- `addHeadComment`: Added a comment to the head of the file.\n\t- `toString`: Returns the string representation of this properties editor object. This string will be written to a file if `save` is called.\n\n## Getting node-properties-parser\n\nThe easiest way to get node-properties-parser is with [npm](http://npmjs.org/):\n\n\tnpm install properties-parser\n\nAlternatively you can clone this git repository:\n\n\tgit://github.com/xavi-/node-properties-parser.git\n\n## Developed by\n* Xavi Ramirez\n\n## License\nThis project is released under [The MIT License](http://www.opensource.org/licenses/mit-license.php).",
|
||||
"readmeFilename": "README.markdown",
|
||||
"bugs": {
|
||||
"url": "https://github.com/xavi-/node-properties-parser/issues"
|
||||
},
|
||||
"homepage": "https://github.com/xavi-/node-properties-parser",
|
||||
"_id": "properties-parser@0.3.0",
|
||||
"scripts": {},
|
||||
"_shasum": "6ba6dc6ac40cf53b1ee2c2045f86623e70213caa",
|
||||
"_from": "properties-parser@>=0.3.0 <0.4.0",
|
||||
"_npmVersion": "2.5.1",
|
||||
"_nodeVersion": "1.2.0",
|
||||
"_npmUser": {
|
||||
"name": "xavi",
|
||||
"email": "xavi.rmz@gmail.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "6ba6dc6ac40cf53b1ee2c2045f86623e70213caa",
|
||||
"tarball": "http://registry.npmjs.org/properties-parser/-/properties-parser-0.3.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/properties-parser/-/properties-parser-0.3.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
"homepage": "https://github.com/xavi-/node-properties-parser#readme",
|
||||
"_id": "properties-parser@0.2.3",
|
||||
"_shasum": "f7591255f707abbff227c7b56b637dbb0373a10f",
|
||||
"_resolved": "https://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz",
|
||||
"_from": "properties-parser@0.2.3"
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
"cordova-common": "^0.1.0",
|
||||
"elementtree": "^0.1.6",
|
||||
"nopt": "^3.0.1",
|
||||
"properties-parser": "^0.3.0",
|
||||
"properties-parser": "^0.2.3",
|
||||
"q": "^1.4.1",
|
||||
"shelljs": "^0.5.3"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user