first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

31
build/node_modules/npm-installed/README.md generated vendored Normal file
View File

@@ -0,0 +1,31 @@
# npm-installed [![Build Status](http://img.shields.io/travis/kevva/npm-installed.svg?style=flat)](https://travis-ci.org/kevva/npm-installed)
> Find programs installed by npm
## Install
```sh
$ npm install --save npm-installed
```
## Usage
```js
var npmInstalled = require('npm-installed');
npmInstalled('imagemin', function (err, path) {
if (err) {
throw err;
}
console.log(path);
//=> /home/sirjohndoe/.npm-packages/bin/imagemin
});
npmInstalled.sync('imagemin');
//=> /home/sirjohndoe/.npm-packages/bin/imagemin
```
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

47
build/node_modules/npm-installed/index.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
'use strict';
var path = require('path');
var prefix = require('rc')('npm').prefix;
var which = require('npm-which');
/**
* Find programs installed by npm
*
* @param {String} file
* @param {Function} cb
* @api public
*/
module.exports = function (file, cb) {
var env = {};
if (prefix) {
env.PATH = path.join(prefix, 'bin');
}
which(file, { env: env } , function (err, res) {
if (err) {
cb(err);
return;
}
cb(null, res);
});
};
/**
* Find programs installed by npm synchronously
*
* @param {Array} file
* @api public
*/
module.exports.sync = function (file) {
var env = {};
if (prefix) {
env.PATH = path.join(prefix, 'bin');
}
return which.sync(file, { env: env });
};

1
build/node_modules/npm-installed/node_modules/.bin/rc generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../rc/index.js

View File

@@ -0,0 +1 @@
../strip-json-comments/cli.js

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Viacheslav Lotsmanov
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,52 @@
Node.JS module “Deep Extend”
============================
Recursive object extending.
Install
-----
npm install deep-extend
Usage
-----
var deepExtend = require('deep-extend');
var obj1 = {
a: 1,
b: 2,
d: {
a: 1,
b: [],
c: { test1: 123, test2: 321 }
},
f: 5,
g: 123
};
var obj2 = {
b: 3,
c: 5,
d: {
b: { first: 'one', second: 'two' },
c: { test2: 222 }
},
e: { one: 1, two: 2 },
f: [],
g: (void 0)
};
deepExtend(obj1, obj2);
console.log(obj1);
/*
{ a: 1,
b: 3,
d:
{ a: 1,
b: { first: 'one', second: 'two' },
c: { test1: 123, test2: 222 } },
f: [],
c: 5,
e: { one: 1, two: 2 },
g: undefined }
*/

View File

@@ -0,0 +1,90 @@
/*!
* Node.JS module "Deep Extend"
* @description Recursive object extending.
* @author Viacheslav Lotsmanov (unclechu) <lotsmanov89@gmail.com>
* @license MIT
*
* The MIT License (MIT)
*
* Copyright (c) 2013 Viacheslav Lotsmanov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Extening object that entered in first argument.
* Returns extended object or false if have no target object or incorrect type.
* If you wish to clone object, simply use that:
* deepExtend({}, yourObj_1, [yourObj_N]) - first arg is new empty object
*/
var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) {
if (arguments.length < 1 || typeof arguments[0] !== 'object') {
return false;
}
if (arguments.length < 2) return arguments[0];
var target = arguments[0];
// convert arguments to array and cut off target object
var args = Array.prototype.slice.call(arguments, 1);
var key, val, src, clone, tmpBuf;
args.forEach(function (obj) {
if (typeof obj !== 'object') return;
for (key in obj) {
if ( ! (key in obj)) continue;
src = target[key];
val = obj[key];
if (val === target) continue;
if (typeof val !== 'object' || val === null) {
target[key] = val;
continue;
} else if (val instanceof Buffer) {
tmpBuf = new Buffer(val.length);
val.copy(tmpBuf);
target[key] = tmpBuf;
continue;
} else if (val instanceof Date) {
target[key] = new Date(val.getTime());
continue;
}
if (typeof src !== 'object' || src === null) {
clone = (Array.isArray(val)) ? [] : {};
target[key] = deepExtend(clone, val);
continue;
}
if (Array.isArray(val)) {
clone = (Array.isArray(src)) ? src : [];
} else {
clone = (!Array.isArray(src)) ? src : {};
}
target[key] = deepExtend(clone, val);
}
});
return target;
}

View File

@@ -0,0 +1,64 @@
{
"_from": "deep-extend@~0.2.5",
"_id": "deep-extend@0.2.11",
"_inBundle": false,
"_integrity": "sha1-eha6aXKRMjQFBhcElLyD9wdv4I8=",
"_location": "/npm-installed/deep-extend",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "deep-extend@~0.2.5",
"name": "deep-extend",
"escapedName": "deep-extend",
"rawSpec": "~0.2.5",
"saveSpec": null,
"fetchSpec": "~0.2.5"
},
"_requiredBy": [
"/npm-installed/rc"
],
"_resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.11.tgz",
"_shasum": "7a16ba69729132340506170494bc83f7076fe08f",
"_spec": "deep-extend@~0.2.5",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/npm-installed/node_modules/rc",
"author": {
"name": "Viacheslav Lotsmanov",
"email": "lotsmanov89@gmail.com",
"url": "unclechu"
},
"bugs": {
"url": "https://github.com/unclechu/node-deep-extend/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Romain Prieto",
"url": "https://github.com/rprieto"
}
],
"deprecated": false,
"description": "Recursive object extending.",
"devDependencies": {
"mocha": "~1.19.0",
"should": "~3.3.2"
},
"directories": {
"test": "./test"
},
"engines": {
"node": ">=0.4"
},
"homepage": "https://github.com/unclechu/node-deep-extend",
"license": "MIT",
"main": "index",
"name": "deep-extend",
"repository": {
"type": "git",
"url": "git://github.com/unclechu/node-deep-extend.git"
},
"scripts": {
"test": "mocha"
},
"version": "0.2.11"
}

View File

@@ -0,0 +1,57 @@
var should = require('should');
var extend = require('../index');
describe('deep-extend', function() {
it('can extend on 1 level', function() {
var a = { hello: 1 };
var b = { world: 2 };
extend(a, b);
a.should.eql({
hello: 1,
world: 2
});
});
it('can extend on 2 levels', function() {
var a = { person: { name: 'John' } };
var b = { person: { age: 30 } };
extend(a, b);
a.should.eql({
person: { name: 'John', age: 30 }
});
});
it('can extend with Buffer values', function() {
var a = { hello: 1 };
var b = { value: new Buffer('world') };
extend(a, b);
a.should.eql({
hello: 1,
value: new Buffer('world')
});
});
it('Buffer is cloned', function () {
var a = { };
var b = { value: new Buffer('foo') };
extend(a, b);
a.value.write('bar');
a.value.toString().should.eql('bar');
b.value.toString().should.eql('foo');
});
it('Date objects', function () {
var a = { d: new Date() };
var b = extend({}, a);
b.d.should.instanceOf(Date);
});
it('Date object is cloned', function () {
var a = { d: new Date() };
var b = extend({}, a);
b.d.setTime( (new Date()).getTime() + 100000 );
b.d.getTime().should.not.eql( a.d.getTime() );
});
});

View File

@@ -0,0 +1 @@
--reporter spec

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- "0.8"
- "0.10"

View File

@@ -0,0 +1,18 @@
This software is released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,2 @@
var argv = require('../')(process.argv.slice(2));
console.dir(argv);

View File

@@ -0,0 +1,187 @@
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { bools : {}, strings : {} };
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
});
var aliases = {};
Object.keys(opts.alias || {}).forEach(function (key) {
aliases[key] = [].concat(opts.alias[key]);
aliases[key].forEach(function (x) {
aliases[x] = [key].concat(aliases[key].filter(function (y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
if (aliases[key]) {
flags.strings[aliases[key]] = true;
}
});
var defaults = opts['default'] || {};
var argv = { _ : [] };
Object.keys(flags.bools).forEach(function (key) {
setArg(key, defaults[key] === undefined ? false : defaults[key]);
});
var notFlags = [];
if (args.indexOf('--') !== -1) {
notFlags = args.slice(args.indexOf('--')+1);
args = args.slice(0, args.indexOf('--'));
}
function setArg (key, val) {
var value = !flags.strings[key] && isNumber(val)
? Number(val) : val
;
setKey(argv, key.split('.'), value);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), value);
});
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (/^--.+=/.test(arg)) {
// Using [\s\S] instead of . because js doesn't support the
// 'dotall' regex modifier. See:
// http://stackoverflow.com/a/1068308/13216
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
setArg(m[1], m[2]);
}
else if (/^--no-.+/.test(arg)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false);
}
else if (/^--.+/.test(arg)) {
var key = arg.match(/^--(.+)/)[1];
var next = args[i + 1];
if (next !== undefined && !/^-/.test(next)
&& !flags.bools[key]
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
setArg(key, next);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next === 'true');
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true);
}
}
else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1,-1).split('');
var broken = false;
for (var j = 0; j < letters.length; j++) {
var next = arg.slice(j+2);
if (next === '-') {
setArg(letters[j], next)
continue;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2));
broken = true;
break;
}
else {
setArg(letters[j], flags.strings[letters[j]] ? '' : true);
}
}
var key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
&& !flags.bools[key]
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
setArg(key, args[i+1]);
i++;
}
else if (args[i+1] && /true|false/.test(args[i+1])) {
setArg(key, args[i+1] === 'true');
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true);
}
}
}
else {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
}
Object.keys(defaults).forEach(function (key) {
if (!hasKey(argv, key.split('.'))) {
setKey(argv, key.split('.'), defaults[key]);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), defaults[key]);
});
}
});
notFlags.forEach(function(key) {
argv._.push(key);
});
return argv;
};
function hasKey (obj, keys) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
o = (o[key] || {});
});
var key = keys[keys.length - 1];
return key in o;
}
function setKey (obj, keys, value) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
o = o[key];
});
var key = keys[keys.length - 1];
if (o[key] === undefined || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
function isNumber (x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}

View File

@@ -0,0 +1,71 @@
{
"_from": "minimist@~0.0.7",
"_id": "minimist@0.0.10",
"_inBundle": false,
"_integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=",
"_location": "/npm-installed/minimist",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "minimist@~0.0.7",
"name": "minimist",
"escapedName": "minimist",
"rawSpec": "~0.0.7",
"saveSpec": null,
"fetchSpec": "~0.0.7"
},
"_requiredBy": [
"/npm-installed/rc"
],
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"_shasum": "de3f98543dbf96082be48ad1a0c7cda836301dcf",
"_spec": "minimist@~0.0.7",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/npm-installed/node_modules/rc",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/minimist/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "parse argument options",
"devDependencies": {
"tap": "~0.4.0",
"tape": "~1.0.4"
},
"homepage": "https://github.com/substack/minimist",
"keywords": [
"argv",
"getopt",
"parser",
"optimist"
],
"license": "MIT",
"main": "index.js",
"name": "minimist",
"repository": {
"type": "git",
"url": "git://github.com/substack/minimist.git"
},
"scripts": {
"test": "tap test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"ff/5",
"firefox/latest",
"chrome/10",
"chrome/latest",
"safari/5.1",
"safari/latest",
"opera/12"
]
},
"version": "0.0.10"
}

View File

@@ -0,0 +1,73 @@
# minimist
parse argument options
This module is the guts of optimist's argument parser without all the
fanciful decoration.
[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)
[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist)
# example
``` js
var argv = require('minimist')(process.argv.slice(2));
console.dir(argv);
```
```
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
```
```
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
```
# methods
``` js
var parseArgs = require('minimist')
```
## var argv = parseArgs(args, opts={})
Return an argument object `argv` populated with the array arguments from `args`.
`argv._` contains all the arguments that didn't have an option associated with
them.
Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
options can be:
* `opts.string` - a string or array of strings argument names to always treat as
strings
* `opts.boolean` - a string or array of strings to always treat as booleans
* `opts.alias` - an object mapping string names to strings or arrays of string
argument names to use as aliases
* `opts.default` - an object mapping string argument names to default values
# install
With [npm](https://npmjs.org) do:
```
npm install minimist
```
# license
MIT

View File

@@ -0,0 +1,119 @@
var parse = require('../');
var test = require('tape');
test('flag boolean default false', function (t) {
var argv = parse(['moo'], {
boolean: ['t', 'verbose'],
default: { verbose: false, t: false }
});
t.deepEqual(argv, {
verbose: false,
t: false,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('boolean groups', function (t) {
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
boolean: ['x','y','z']
});
t.deepEqual(argv, {
x : true,
y : false,
z : true,
_ : [ 'one', 'two', 'three' ]
});
t.deepEqual(typeof argv.x, 'boolean');
t.deepEqual(typeof argv.y, 'boolean');
t.deepEqual(typeof argv.z, 'boolean');
t.end();
});
test('boolean and alias with chainable api', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
herp: { alias: 'h', boolean: true }
};
var aliasedArgv = parse(aliased, {
boolean: 'herp',
alias: { h: 'herp' }
});
var propertyArgv = parse(regular, {
boolean: 'herp',
alias: { h: 'herp' }
});
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
alias: { 'h': 'herp' },
boolean: 'herp'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias using explicit true', function (t) {
var aliased = [ '-h', 'true' ];
var regular = [ '--herp', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
// regression, see https://github.com/substack/node-optimist/issues/71
test('boolean and --x=true', function(t) {
var parsed = parse(['--boool', '--other=true'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'true');
parsed = parse(['--boool', '--other=false'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'false');
t.end();
});

View File

@@ -0,0 +1,24 @@
var parse = require('../');
var test = require('tape');
test('-', function (t) {
t.plan(5);
t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] });
t.deepEqual(parse([ '-' ]), { _: [ '-' ] });
t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] });
t.deepEqual(
parse([ '-b', '-' ], { boolean: 'b' }),
{ b: true, _: [ '-' ] }
);
t.deepEqual(
parse([ '-s', '-' ], { string: 's' }),
{ s: '-', _: [] }
);
});
test('-a -- b', function (t) {
t.plan(3);
t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
});

View File

@@ -0,0 +1,20 @@
var test = require('tape');
var parse = require('../');
test('boolean default true', function (t) {
var argv = parse([], {
boolean: 'sometrue',
default: { sometrue: true }
});
t.equal(argv.sometrue, true);
t.end();
});
test('boolean default false', function (t) {
var argv = parse([], {
boolean: 'somefalse',
default: { somefalse: false }
});
t.equal(argv.somefalse, false);
t.end();
});

View File

@@ -0,0 +1,22 @@
var parse = require('../');
var test = require('tape');
test('dotted alias', function (t) {
var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 22);
t.equal(argv.aa.bb, 22);
t.end();
});
test('dotted default', function (t) {
var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 11);
t.equal(argv.aa.bb, 11);
t.end();
});
test('dotted default with no alias', function (t) {
var argv = parse('', {default: {'a.b': 11}});
t.equal(argv.a.b, 11);
t.end();
});

View File

@@ -0,0 +1,31 @@
var test = require('tape');
var parse = require('../');
test('long opts', function (t) {
t.deepEqual(
parse([ '--bool' ]),
{ bool : true, _ : [] },
'long boolean'
);
t.deepEqual(
parse([ '--pow', 'xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture sp'
);
t.deepEqual(
parse([ '--pow=xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture eq'
);
t.deepEqual(
parse([ '--host', 'localhost', '--port', '555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures sp'
);
t.deepEqual(
parse([ '--host=localhost', '--port=555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures eq'
);
t.end();
});

View File

@@ -0,0 +1,36 @@
var parse = require('../');
var test = require('tape');
test('nums', function (t) {
var argv = parse([
'-x', '1234',
'-y', '5.67',
'-z', '1e7',
'-w', '10f',
'--hex', '0xdeadbeef',
'789'
]);
t.deepEqual(argv, {
x : 1234,
y : 5.67,
z : 1e7,
w : '10f',
hex : 0xdeadbeef,
_ : [ 789 ]
});
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv.y, 'number');
t.deepEqual(typeof argv.z, 'number');
t.deepEqual(typeof argv.w, 'string');
t.deepEqual(typeof argv.hex, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});
test('already a number', function (t) {
var argv = parse([ '-x', 1234, 789 ]);
t.deepEqual(argv, { x : 1234, _ : [ 789 ] });
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});

View File

@@ -0,0 +1,197 @@
var parse = require('../');
var test = require('tape');
test('parse args', function (t) {
t.deepEqual(
parse([ '--no-moo' ]),
{ moo : false, _ : [] },
'no'
);
t.deepEqual(
parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),
{ v : ['a','b','c'], _ : [] },
'multi'
);
t.end();
});
test('comprehensive', function (t) {
t.deepEqual(
parse([
'--name=meowmers', 'bare', '-cats', 'woo',
'-h', 'awesome', '--multi=quux',
'--key', 'value',
'-b', '--bool', '--no-meep', '--multi=baz',
'--', '--not-a-flag', 'eek'
]),
{
c : true,
a : true,
t : true,
s : 'woo',
h : 'awesome',
b : true,
bool : true,
key : 'value',
multi : [ 'quux', 'baz' ],
meep : false,
name : 'meowmers',
_ : [ 'bare', '--not-a-flag', 'eek' ]
}
);
t.end();
});
test('flag boolean', function (t) {
var argv = parse([ '-t', 'moo' ], { boolean: 't' });
t.deepEqual(argv, { t : true, _ : [ 'moo' ] });
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('flag boolean value', function (t) {
var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], {
boolean: [ 't', 'verbose' ],
default: { verbose: true }
});
t.deepEqual(argv, {
verbose: false,
t: true,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('newlines in params' , function (t) {
var args = parse([ '-s', "X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
// reproduce in bash:
// VALUE="new
// line"
// node program.js --s="$VALUE"
args = parse([ "--s=X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
t.end();
});
test('strings' , function (t) {
var s = parse([ '-s', '0001234' ], { string: 's' }).s;
t.equal(s, '0001234');
t.equal(typeof s, 'string');
var x = parse([ '-x', '56' ], { string: 'x' }).x;
t.equal(x, '56');
t.equal(typeof x, 'string');
t.end();
});
test('stringArgs', function (t) {
var s = parse([ ' ', ' ' ], { string: '_' })._;
t.same(s.length, 2);
t.same(typeof s[0], 'string');
t.same(s[0], ' ');
t.same(typeof s[1], 'string');
t.same(s[1], ' ');
t.end();
});
test('empty strings', function(t) {
var s = parse([ '-s' ], { string: 's' }).s;
t.equal(s, '');
t.equal(typeof s, 'string');
var str = parse([ '--str' ], { string: 'str' }).str;
t.equal(str, '');
t.equal(typeof str, 'string');
var letters = parse([ '-art' ], {
string: [ 'a', 't' ]
});
t.equal(letters.a, '');
t.equal(letters.r, true);
t.equal(letters.t, '');
t.end();
});
test('string and alias', function(t) {
var x = parse([ '--str', '000123' ], {
string: 's',
alias: { s: 'str' }
});
t.equal(x.str, '000123');
t.equal(typeof x.str, 'string');
t.equal(x.s, '000123');
t.equal(typeof x.s, 'string');
var y = parse([ '-s', '000123' ], {
string: 'str',
alias: { str: 's' }
});
t.equal(y.str, '000123');
t.equal(typeof y.str, 'string');
t.equal(y.s, '000123');
t.equal(typeof y.s, 'string');
t.end();
});
test('slashBreak', function (t) {
t.same(
parse([ '-I/foo/bar/baz' ]),
{ I : '/foo/bar/baz', _ : [] }
);
t.same(
parse([ '-xyz/foo/bar/baz' ]),
{ x : true, y : true, z : '/foo/bar/baz', _ : [] }
);
t.end();
});
test('alias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: 'zoom' }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.f, 11);
t.end();
});
test('multiAlias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: [ 'zm', 'zoom' ] }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.z, argv.zm);
t.equal(argv.f, 11);
t.end();
});
test('nested dotted objects', function (t) {
var argv = parse([
'--foo.bar', '3', '--foo.baz', '4',
'--foo.quux.quibble', '5', '--foo.quux.o_O',
'--beep.boop'
]);
t.same(argv.foo, {
bar : 3,
baz : 4,
quux : {
quibble : 5,
o_O : true
}
});
t.same(argv.beep, { boop : true });
t.end();
});

View File

@@ -0,0 +1,9 @@
var parse = require('../');
var test = require('tape');
test('parse with modifier functions' , function (t) {
t.plan(1);
var argv = parse([ '-b', '123' ], { boolean: 'b' });
t.deepEqual(argv, { b: true, _: ['123'] });
});

View File

@@ -0,0 +1,67 @@
var parse = require('../');
var test = require('tape');
test('numeric short args', function (t) {
t.plan(2);
t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] });
t.deepEqual(
parse([ '-123', '456' ]),
{ 1: true, 2: true, 3: 456, _: [] }
);
});
test('short', function (t) {
t.deepEqual(
parse([ '-b' ]),
{ b : true, _ : [] },
'short boolean'
);
t.deepEqual(
parse([ 'foo', 'bar', 'baz' ]),
{ _ : [ 'foo', 'bar', 'baz' ] },
'bare'
);
t.deepEqual(
parse([ '-cats' ]),
{ c : true, a : true, t : true, s : true, _ : [] },
'group'
);
t.deepEqual(
parse([ '-cats', 'meow' ]),
{ c : true, a : true, t : true, s : 'meow', _ : [] },
'short group next'
);
t.deepEqual(
parse([ '-h', 'localhost' ]),
{ h : 'localhost', _ : [] },
'short capture'
);
t.deepEqual(
parse([ '-h', 'localhost', '-p', '555' ]),
{ h : 'localhost', p : 555, _ : [] },
'short captures'
);
t.end();
});
test('mixed short bool and capture', function (t) {
t.same(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});
test('short and long', function (t) {
t.deepEqual(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});

View File

@@ -0,0 +1,8 @@
var parse = require('../');
var test = require('tape');
test('whitespace should be whitespace' , function (t) {
t.plan(1);
var x = parse([ '-x', '\t' ]).x;
t.equal(x, '\t');
});

View File

@@ -0,0 +1,3 @@
node_modules
node_modules/*
npm_debug.log

View File

@@ -0,0 +1,15 @@
Apache License, Version 2.0
Copyright (c) 2011 Dominic Tarr
Licensed 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.

View File

@@ -0,0 +1,26 @@
Copyright (c) 2013, Dominic Tarr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

View File

@@ -0,0 +1,24 @@
The MIT License
Copyright (c) 2011 Dominic Tarr
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,128 @@
# rc
The non-configurable configuration loader for lazy people.
## Usage
The only option is to pass rc the name of your app, and your default configuration.
```javascript
var conf = require('rc')(appname, {
//defaults go here.
port: 2468,
//defaults which are objects will be merged, not replaced
views: {
engine: 'jade'
}
});
```
`rc` will return your configuration options merged with the defaults you specify.
If you pass in a predefined defaults object, it will be mutated:
```javascript
var conf = {};
require('rc')(appname, conf);
```
## Standards
Given your application name (`appname`), rc will look in all the obvious places for configuration.
* command line arguments (parsed by minimist)
* environment variables prefixed with `${appname}_`
* or use "\_\_" to indicate nested properties <br/> _(e.g. `appname_foo__bar__baz` => `foo.bar.baz`)_
* if you passed an option `--config file` then from that file
* a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc.
* `$HOME/.${appname}rc`
* `$HOME/.${appname}/config`
* `$HOME/.config/${appname}`
* `$HOME/.config/${appname}/config`
* `/etc/${appname}rc`
* `/etc/${appname}/config`
* the defaults object you passed in.
All configuration sources that were found will be flattened into one object,
so that sources **earlier** in this list override later ones.
## Configuration File Formats
Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. The example configurations below are equivalent:
#### Formatted as `ini`
```
; You can include comments in `ini` format if you want.
dependsOn=0.10.0
; `rc` has built-in support for ini sections, see?
[commands]
www = ./commands/www
console = ./commands/repl
; You can even do nested sections
[generators.options]
engine = ejs
[generators.modules]
new = generate-new
engine = generate-backend
```
#### Formatted as `json`
```json
{
// You can even comment your JSON, if you want
"dependsOn": "0.10.0",
"commands": {
"www": "./commands/www",
"console": "./commands/repl"
},
"generators": {
"options": {
"engine": "ejs"
},
"modules": {
"new": "generate-new",
"backend": "generate-backend"
}
}
}
```
Comments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).
> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.
## Advanced Usage
#### Pass in your own `argv`
You may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12).
```javascript
require('rc')(appname, defaults, customArgvParser);
```
## Note on Performance
`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler)
## License
BSD / MIT / Apache2

View File

@@ -0,0 +1,7 @@
// when this is loaded into the browser,
// just use the defaults...
module.exports = function (name, defaults) {
return defaults
}

46
build/node_modules/npm-installed/node_modules/rc/index.js generated vendored Executable file
View File

@@ -0,0 +1,46 @@
#! /usr/bin/env node
var cc = require('./lib/utils')
var join = require('path').join
var deepExtend = require('deep-extend')
var etc = '/etc'
var win = process.platform === "win32"
var home = win
? process.env.USERPROFILE
: process.env.HOME
module.exports = function (name, defaults, argv) {
if('string' !== typeof name)
throw new Error('rc(name): name *must* be string')
if(!argv)
argv = require('minimist')(process.argv.slice(2))
defaults = (
'string' === typeof defaults
? cc.json(defaults) : defaults
) || {}
var local = cc.find('.'+name+'rc')
var env = cc.env(name + '_')
return deepExtend.apply(null, [
defaults,
win ? {} : cc.json(join(etc, name, 'config')),
win ? {} : cc.json(join(etc, name + 'rc')),
home ? cc.json(join(home, '.config', name, 'config')) : {},
home ? cc.json(join(home, '.config', name)) : {},
home ? cc.json(join(home, '.' + name, 'config')) : {},
home ? cc.json(join(home, '.' + name + 'rc')) : {},
cc.json(local),
local ? {config: local} : null,
env.config ? cc.json(env.config) : null,
argv.config ? cc.json(argv.config) : null,
env,
argv
])
}
if(!module.parent) {
console.log(
JSON.stringify(module.exports(process.argv[2]), false, 2)
)
}

View File

@@ -0,0 +1,97 @@
var fs = require('fs')
var ini = require('ini')
var path = require('path')
var stripJsonComments = require('strip-json-comments')
var parse = exports.parse = function (content, file) {
//if it ends in .json or starts with { then it must be json.
//must be done this way, because ini accepts everything.
//can't just try and parse it and let it throw if it's not ini.
//everything is ini. even json with a systax error.
if((file && /\.json$/.test(file)) || /^\s*{/.test(content))
return JSON.parse(stripJsonComments(content))
return ini.parse(content)
}
var json = exports.json = function () {
var args = [].slice.call(arguments).filter(function (arg) { return arg != null })
//path.join breaks if it's a not a string, so just skip this.
for(var i in args)
if('string' !== typeof args[i])
return
var file = path.join.apply(null, args)
var content
try {
content = fs.readFileSync(file,'utf-8')
} catch (err) {
return
}
return parse(content)
}
var env = exports.env = function (prefix, env) {
env = env || process.env
var obj = {}
var l = prefix.length
for(var k in env) {
if((k.indexOf(prefix)) === 0) {
var keypath = k.substring(l).split('__')
// Trim empty strings from keypath array
var _emptyStringIndex
while ((_emptyStringIndex=keypath.indexOf('')) > -1) {
keypath.splice(_emptyStringIndex, 1)
}
var cursor = obj
keypath.forEach(function _buildSubObj(_subkey,i){
// (check for _subkey first so we ignore empty strings)
if (!_subkey)
return
// If this is the last key, just stuff the value in there
// Assigns actual value from env variable to final key
// (unless it's just an empty string- in that case use the last valid key)
if (i === keypath.length-1)
cursor[_subkey] = env[k]
// Build sub-object if nothing already exists at the keypath
if (cursor[_subkey] === undefined)
cursor[_subkey] = {}
// Increment cursor used to track the object at the current depth
cursor = cursor[_subkey]
})
}
}
return obj
}
var find = exports.find = function () {
var rel = path.join.apply(null, [].slice.call(arguments))
function find(start, rel) {
var file = path.join(start, rel)
try {
fs.statSync(file)
return file
} catch (err) {
if(path.dirname(start) !== start) // root
return find(path.dirname(start), rel)
}
}
return find(process.cwd(), rel)
}

View File

@@ -0,0 +1,68 @@
{
"_from": "rc@^0.5.1",
"_id": "rc@0.5.5",
"_inBundle": false,
"_integrity": "sha1-VBzDMA9GS23+ZDLXVvDy3T6esZk=",
"_location": "/npm-installed/rc",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "rc@^0.5.1",
"name": "rc",
"escapedName": "rc",
"rawSpec": "^0.5.1",
"saveSpec": null,
"fetchSpec": "^0.5.1"
},
"_requiredBy": [
"/npm-installed"
],
"_resolved": "https://registry.npmjs.org/rc/-/rc-0.5.5.tgz",
"_shasum": "541cc3300f464b6dfe6432d756f0f2dd3e9eb199",
"_spec": "rc@^0.5.1",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/npm-installed",
"author": {
"name": "Dominic Tarr",
"email": "dominic.tarr@gmail.com",
"url": "dominictarr.com"
},
"bin": {
"rc": "./index.js"
},
"browserify": "browser.js",
"bugs": {
"url": "https://github.com/dominictarr/rc/issues"
},
"bundleDependencies": false,
"dependencies": {
"deep-extend": "~0.2.5",
"ini": "~1.3.0",
"minimist": "~0.0.7",
"strip-json-comments": "0.1.x"
},
"deprecated": false,
"description": "hardwired configuration loader",
"homepage": "https://github.com/dominictarr/rc#readme",
"keywords": [
"config",
"rc",
"unix",
"defaults"
],
"licenses": [
"BSD",
"MIT",
"Apache2"
],
"main": "index.js",
"name": "rc",
"repository": {
"type": "git",
"url": "git+https://github.com/dominictarr/rc.git"
},
"scripts": {
"test": "set -e; node test/test.js; node test/ini.js; node test/nested-env-vars.js"
},
"version": "0.5.5"
}

View File

@@ -0,0 +1,16 @@
var cc =require('../lib/utils')
var INI = require('ini')
var assert = require('assert')
function test(obj) {
var _json, _ini
var json = cc.parse (_json = JSON.stringify(obj))
var ini = cc.parse (_ini = INI.stringify(obj))
console.log(_ini, _json)
assert.deepEqual(json, ini)
}
test({hello: true})

View File

@@ -0,0 +1,39 @@
var n = 'rc'+Math.random()
var assert = require('assert')
// Basic usage
process.env[n+'_someOpt__a'] = 42
process.env[n+'_someOpt__x__'] = 99
process.env[n+'_someOpt__a__b'] = 186
process.env[n+'_someOpt__x__y'] = 1862
process.env[n+'_someOpt__z'] = 186577
// Should ignore empty strings from orphaned '__'
process.env[n+'_someOpt__z__x__'] = 18629
process.env[n+'_someOpt__w__w__'] = 18629
// Leading '__' should ignore everything up to 'z'
process.env[n+'___z__i__'] = 9999
var config = require('../')(n, {
option: true
})
console.log('\n\n------ nested-env-vars ------\n',config)
assert.equal(config.option, true)
assert.equal(config.someOpt.a, 42)
assert.equal(config.someOpt.x, 99)
// Should not override `a` once it's been set
assert.equal(config.someOpt.a/*.b*/, 42)
// Should not override `x` once it's been set
assert.equal(config.someOpt.x/*.y*/, 99)
assert.equal(config.someOpt.z, 186577)
// Should not override `z` once it's been set
assert.equal(config.someOpt.z/*.x*/, 186577)
assert.equal(config.someOpt.w.w, 18629)
assert.equal(config.z.i, 9999)

View File

@@ -0,0 +1,56 @@
var n = 'rc'+Math.random()
var assert = require('assert')
process.env[n+'_envOption'] = 42
var config = require('../')(n, {
option: true
})
console.log(config)
assert.equal(config.option, true)
assert.equal(config.envOption, 42)
var customArgv = require('../')(n, {
option: true
}, { // nopt-like argv
option: false,
envOption: 24,
argv: {
remain: [],
cooked: ['--no-option', '--envOption', '24'],
original: ['--no-option', '--envOption=24']
}
})
console.log(customArgv)
assert.equal(customArgv.option, false)
assert.equal(customArgv.envOption, 24)
var fs = require('fs')
var path = require('path')
var jsonrc = path.resolve('.' + n + 'rc');
fs.writeFileSync(jsonrc, [
'{',
'// json overrides default',
'"option": false,',
'/* env overrides json */',
'"envOption": 24',
'}'
].join('\n'));
var commentedJSON = require('../')(n, {
option: true
})
fs.unlinkSync(jsonrc);
console.log(commentedJSON)
assert.equal(commentedJSON.option, false)
assert.equal(commentedJSON.envOption, 42)
assert.equal(commentedJSON.config, jsonrc)

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var strip = require('./strip-json-comments');
var input = process.argv[2];
function getStdin(cb) {
var ret = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
ret += data;
});
process.stdin.on('end', function () {
cb(ret);
});
}
if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
console.log('strip-json-comments <input file> > <output file>');
console.log('or');
console.log('cat <input file> | strip-json-comments > <output file>');
return;
}
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
console.log(require('./package').version);
return;
}
if (input) {
process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
return;
}
getStdin(function (data) {
process.stdout.write(strip(data));
});

View File

@@ -0,0 +1,80 @@
{
"_from": "strip-json-comments@0.1.x",
"_id": "strip-json-comments@0.1.3",
"_inBundle": false,
"_integrity": "sha1-Fkxk43Coo8wAyeAbU55WmCPw7lQ=",
"_location": "/npm-installed/strip-json-comments",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "strip-json-comments@0.1.x",
"name": "strip-json-comments",
"escapedName": "strip-json-comments",
"rawSpec": "0.1.x",
"saveSpec": null,
"fetchSpec": "0.1.x"
},
"_requiredBy": [
"/npm-installed/rc"
],
"_resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz",
"_shasum": "164c64e370a8a3cc00c9e01b539e569823f0ee54",
"_spec": "strip-json-comments@0.1.x",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/npm-installed/node_modules/rc",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"bin": {
"strip-json-comments": "cli.js"
},
"bugs": {
"url": "https://github.com/sindresorhus/strip-json-comments/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Strip comments from JSON. Lets you use comments in your JSON files!",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.8.0"
},
"files": [
"cli.js",
"strip-json-comments.js"
],
"homepage": "https://github.com/sindresorhus/strip-json-comments#readme",
"keywords": [
"json",
"strip",
"remove",
"delete",
"trim",
"comments",
"multiline",
"parse",
"config",
"configuration",
"conf",
"settings",
"util",
"env",
"environment",
"cli",
"bin"
],
"license": "MIT",
"main": "strip-json-comments",
"name": "strip-json-comments",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/strip-json-comments.git"
},
"scripts": {
"test": "mocha"
},
"version": "0.1.3"
}

View File

@@ -0,0 +1,74 @@
# strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments)
> Strip comments from JSON. Lets you use comments in your JSON files!
This is now possible:
```js
{
// rainbows
"unicorn": /* ❤ */ "cake"
}
```
It will remove single-line comments `//` and mult-line comments `/**/`.
Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin and a [require hook](https://github.com/uTest/autostrip-json-comments).
*There's already [json-comments](https://npmjs.org/package/json-comments), but it's only for Node.js and uses a naive regex to strip comments which fails on simple cases like `{"a":"//"}`. This module however parses out the comments.*
## Install
```sh
$ npm install --save strip-json-comments
```
```sh
$ bower install --save strip-json-comments
```
```sh
$ component install sindresorhus/strip-json-comments
```
## Usage
```js
var json = '{/*rainbows*/"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}
```
## API
### stripJsonComments(input)
#### input
Type: `string`
Accepts a string with JSON and returns a string without comments.
## CLI
```sh
$ npm install --global strip-json-comments
```
```sh
$ strip-json-comments --help
strip-json-comments <input-file> > <output-file>
# or
cat <input-file> | strip-json-comments > <output-file>
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,64 @@
/*!
strip-json-comments
Strip comments from JSON. Lets you use comments in your JSON files!
https://github.com/sindresorhus/strip-json-comments
by Sindre Sorhus
MIT License
*/
(function () {
'use strict';
function stripJsonComments(str) {
var currentChar;
var nextChar;
var insideString = false;
var insideComment = false;
var ret = '';
for (var i = 0; i < str.length; i++) {
currentChar = str[i];
nextChar = str[i + 1];
if (!insideComment && str[i - 1] !== '\\' && currentChar === '"') {
insideString = !insideString;
}
if (insideString) {
ret += currentChar;
continue;
}
if (!insideComment && currentChar + nextChar === '//') {
insideComment = 'single';
i++;
} else if (insideComment === 'single' && currentChar + nextChar === '\r\n') {
insideComment = false;
i++;
} else if (insideComment === 'single' && currentChar === '\n') {
insideComment = false;
} else if (!insideComment && currentChar + nextChar === '/*') {
insideComment = 'multi';
i++;
continue;
} else if (insideComment === 'multi' && currentChar + nextChar === '*/') {
insideComment = false;
i++;
continue;
}
if (insideComment) {
continue;
}
ret += currentChar;
}
return ret;
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = stripJsonComments;
} else {
window.stripJsonComments = stripJsonComments;
}
})();

68
build/node_modules/npm-installed/package.json generated vendored Normal file
View File

@@ -0,0 +1,68 @@
{
"_from": "npm-installed@^1.0.0",
"_id": "npm-installed@1.0.0",
"_inBundle": false,
"_integrity": "sha1-KWHZd/k/0NNx2rNx6YkSDP+mQBg=",
"_location": "/npm-installed",
"_phantomChildren": {
"ini": "1.3.5"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "npm-installed@^1.0.0",
"name": "npm-installed",
"escapedName": "npm-installed",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/pngout-bin/bin-wrapper"
],
"_resolved": "https://registry.npmjs.org/npm-installed/-/npm-installed-1.0.0.tgz",
"_shasum": "2961d977f93fd0d371dab371e989120cffa64018",
"_spec": "npm-installed@^1.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/pngout-bin/node_modules/bin-wrapper",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/npm-installed/issues"
},
"bundleDependencies": false,
"dependencies": {
"npm-which": "^1.0.1",
"rc": "^0.5.1"
},
"deprecated": false,
"description": "Find npm installed programs",
"devDependencies": {
"ava": "^0.0.4"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/npm-installed#readme",
"keywords": [
"bin",
"global",
"path",
"program"
],
"license": "MIT",
"name": "npm-installed",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/npm-installed.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.0.0"
}