initial commit

This commit is contained in:
Mahdi Dibaiee 2015-01-22 22:56:00 +03:30
parent 0f105619ee
commit 6c15977285
94 changed files with 43540 additions and 0 deletions

3
.jshintrc Normal file
View File

@ -0,0 +1,3 @@
{
"esnext": true
}

624
build.js Normal file
View File

@ -0,0 +1,624 @@
"use strict";
"format register";
(function (global) {
var defined = {};
// indexOf polyfill for IE8
var indexOf = Array.prototype.indexOf || function (item) {
for (var i = 0,
l = this.length; i < l; i++) if (this[i] === item) return i;
return -1;
};
function dedupe(deps) {
var newDeps = [];
for (var i = 0,
l = deps.length; i < l; i++) if (indexOf.call(newDeps, deps[i]) == -1) newDeps.push(deps[i]);
return newDeps;
}
function register(name, deps, declare, execute) {
if (typeof name != "string") throw "System.register provided no module name";
var entry;
// dynamic
if (typeof declare == "boolean") {
entry = {
declarative: false,
deps: deps,
execute: execute,
executingRequire: declare
};
} else {
// ES6 declarative
entry = {
declarative: true,
deps: deps,
declare: declare
};
}
entry.name = name;
// we never overwrite an existing define
if (!defined[name]) defined[name] = entry;
entry.deps = dedupe(entry.deps);
// we have to normalize dependencies
// (assume dependencies are normalized for now)
// entry.normalizedDeps = entry.deps.map(normalize);
entry.normalizedDeps = entry.deps;
}
function buildGroups(entry, groups) {
groups[entry.groupIndex] = groups[entry.groupIndex] || [];
if (indexOf.call(groups[entry.groupIndex], entry) != -1) return;
groups[entry.groupIndex].push(entry);
for (var i = 0,
l = entry.normalizedDeps.length; i < l; i++) {
var depName = entry.normalizedDeps[i];
var depEntry = defined[depName];
// not in the registry means already linked / ES6
if (!depEntry || depEntry.evaluated) continue;
// now we know the entry is in our unlinked linkage group
var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
// the group index of an entry is always the maximum
if (depEntry.groupIndex === undefined || depEntry.groupIndex < depGroupIndex) {
// if already in a group, remove from the old group
if (depEntry.groupIndex !== undefined) {
groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
// if the old group is empty, then we have a mixed depndency cycle
if (groups[depEntry.groupIndex].length == 0) throw new TypeError("Mixed dependency cycle detected");
}
depEntry.groupIndex = depGroupIndex;
}
buildGroups(depEntry, groups);
}
}
function link(name) {
var startEntry = defined[name];
startEntry.groupIndex = 0;
var groups = [];
buildGroups(startEntry, groups);
var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
for (var i = groups.length - 1; i >= 0; i--) {
var group = groups[i];
for (var j = 0; j < group.length; j++) {
var entry = group[j];
// link each group
if (curGroupDeclarative) linkDeclarativeModule(entry);else linkDynamicModule(entry);
}
curGroupDeclarative = !curGroupDeclarative;
}
}
// module binding records
var moduleRecords = {};
function getOrCreateModuleRecord(name) {
return moduleRecords[name] || (moduleRecords[name] = {
name: name,
dependencies: [],
exports: {}, // start from an empty module and extend
importers: []
});
}
function linkDeclarativeModule(entry) {
// only link if already not already started linking (stops at circular)
if (entry.module) return;
var module = entry.module = getOrCreateModuleRecord(entry.name);
var exports = entry.module.exports;
var declaration = entry.declare.call(global, function (name, value) {
module.locked = true;
exports[name] = value;
for (var i = 0,
l = module.importers.length; i < l; i++) {
var importerModule = module.importers[i];
if (!importerModule.locked) {
var importerIndex = indexOf.call(importerModule.dependencies, module);
importerModule.setters[importerIndex](exports);
}
}
module.locked = false;
return value;
});
module.setters = declaration.setters;
module.execute = declaration.execute;
if (!module.setters || !module.execute) throw new TypeError("Invalid System.register form for " + entry.name);
// now link all the module dependencies
for (var i = 0,
l = entry.normalizedDeps.length; i < l; i++) {
var depName = entry.normalizedDeps[i];
var depEntry = defined[depName];
var depModule = moduleRecords[depName];
// work out how to set depExports based on scenarios...
var depExports;
if (depModule) {
depExports = depModule.exports;
} else if (depEntry && !depEntry.declarative) {
depExports = { "default": depEntry.module.exports, __useDefault: true };
}
// in the module registry
else if (!depEntry) {
depExports = load(depName);
}
// we have an entry -> link
else {
linkDeclarativeModule(depEntry);
depModule = depEntry.module;
depExports = depModule.exports;
}
// only declarative modules have dynamic bindings
if (depModule && depModule.importers) {
depModule.importers.push(module);
module.dependencies.push(depModule);
} else module.dependencies.push(null);
// run the setter for this dependency
if (module.setters[i]) module.setters[i](depExports);
}
}
// An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
function getModule(name) {
var exports;
var entry = defined[name];
if (!entry) {
exports = load(name);
if (!exports) throw new Error("Unable to load dependency " + name + ".");
} else {
if (entry.declarative) ensureEvaluated(name, []);else if (!entry.evaluated) linkDynamicModule(entry);
exports = entry.module.exports;
}
if ((!entry || entry.declarative) && exports && exports.__useDefault) return exports["default"];
return exports;
}
function linkDynamicModule(entry) {
if (entry.module) return;
var exports = {};
var module = entry.module = { exports: exports, id: entry.name };
// AMD requires execute the tree first
if (!entry.executingRequire) {
for (var i = 0,
l = entry.normalizedDeps.length; i < l; i++) {
var depName = entry.normalizedDeps[i];
var depEntry = defined[depName];
if (depEntry) linkDynamicModule(depEntry);
}
}
// now execute
entry.evaluated = true;
var output = entry.execute.call(global, function (name) {
for (var i = 0,
l = entry.deps.length; i < l; i++) {
if (entry.deps[i] != name) continue;
return getModule(entry.normalizedDeps[i]);
}
throw new TypeError("Module " + name + " not declared as a dependency.");
}, exports, module);
if (output) module.exports = output;
}
/*
* Given a module, and the list of modules for this current branch,
* ensure that each of the dependencies of this module is evaluated
* (unless one is a circular dependency already in the list of seen
* modules, in which case we execute it)
*
* Then we evaluate the module itself depth-first left to right
* execution to match ES6 modules
*/
function ensureEvaluated(moduleName, seen) {
var entry = defined[moduleName];
// if already seen, that means it's an already-evaluated non circular dependency
if (entry.evaluated || !entry.declarative) return;
// this only applies to declarative modules which late-execute
seen.push(moduleName);
for (var i = 0,
l = entry.normalizedDeps.length; i < l; i++) {
var depName = entry.normalizedDeps[i];
if (indexOf.call(seen, depName) == -1) {
if (!defined[depName]) load(depName);else ensureEvaluated(depName, seen);
}
}
if (entry.evaluated) return;
entry.evaluated = true;
entry.module.execute.call(global);
}
// magical execution function
var modules = {};
function load(name) {
if (modules[name]) return modules[name];
var entry = defined[name];
// first we check if this module has already been defined in the registry
if (!entry) throw "Module " + name + " not present.";
// recursively ensure that the module and all its
// dependencies are linked (with dependency group handling)
link(name);
// now handle dependency execution in correct order
ensureEvaluated(name, []);
// remove from the registry
defined[name] = undefined;
var module = entry.declarative ? entry.module.exports : { "default": entry.module.exports, __useDefault: true };
// return the defined module object
return modules[name] = module;
};
return function (main, declare) {
var System;
// if there's a system loader, define onto it
if (typeof System != "undefined" && System.register) {
declare(System);
System["import"](main);
}
// otherwise, self execute
else {
declare(System = {
register: register,
get: load,
set: function (name, module) {
modules[name] = module;
},
newModule: function (module) {
return module;
},
global: global
});
load(main);
}
};
})(typeof window != "undefined" ? window : global)
/* ('mainModule', function(System) {
System.register(...);
}); */
("src/main", function (System) {
System.register("src/lib/vector", [], true, function (require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
function Vector() {
var x = arguments[0] === undefined ? 0 : arguments[0];
var y = arguments[1] === undefined ? 0 : arguments[1];
var z = arguments[2] === undefined ? 0 : arguments[2];
if (!(this instanceof Vector)) return new Vector(x, y, z);
this.x = x;
this.y = y;
this.z = z;
return this;
}
Vector.prototype.invert = function () {
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
};
Vector.prototype.magnitude = function () {
return Math.sqrt(this.magnitude2());
};
Vector.prototype.magnitude2 = function () {
return this.x * this.x + this.y * this.y + this.z * this.z;
};
Vector.prototype.normalize = function () {
var magnitude = this.magnitude();
if (this.magnitude() <= 0) return this;
return this.scalar(1 / magnitude);
};
Vector.prototype.scalar = function () {
var n = arguments[0] === undefined ? 1 : arguments[0];
this.x *= n;
this.y *= n;
this.z *= n;
return this;
};
Vector.prototype.clone = function () {
return new Vector(this.x, this.y, this.z);
};
Vector.prototype.add = function (vec) {
this.x += vec.x;
this.y += vec.y;
this.z += vec.z;
return this;
};
Vector.prototype.component = function (vec) {
this.x *= vec.x;
this.y *= vec.y;
this.z *= vec.z;
return this;
};
Vector.prototype.dot = function (vec) {
return this.x * vec.x + this.y * vec.y + this.z * vec.z;
};
Vector.prototype.cross = function (vec) {
this.x = this.y * vec.z - this.z * vec.y;
this.y = this.x * vec.z - this.z * vec.x;
this.z = this.x * vec.y - this.y * vec.x;
return this;
};
Vector.orthonormal = function (v1, v2) {
var v1xv2 = v1.clone().cross(v2);
v2 = v1xv2.clone().cross(v1);
return [v1.normalize(), v2.normalize(), v1xv2.normalize()];
};
function randomRange(min, max) {
return Math.random() * (max - min) + min;
}
Vector.random = function (x, y, z) {
return new Vector(randomRange(x[0], x[1]), randomRange(y[0], y[1]), randomRange(z[0], z[1]));
};
function killNaN(a) {
if (isNaN(a)) return 0;
return a;
}
module.exports = Vector;
global.define = __define;
return module.exports;
});
System.register("src/lib/particle", ["src/lib/vector", "src/main"], function ($__export) {
"use strict";
var __moduleName = "src/lib/particle";
var Vector, Bolt;
function Particle() {
var properties = arguments[0] !== void 0 ? arguments[0] : {};
if (!(this instanceof Particle)) return new Particle(properties);
this.position = properties.position || new Vector();
this.velocity = properties.velocity || new Vector();
this.acceleration = properties.acceleration || new Vector();
this.damping = properties.damping || 0.95;
this.mass = properties.mass || 10;
Bolt.objects.push(this);
}
return {
setters: [function (m) {
Vector = m["default"];
}, function (m) {
Bolt = m["default"];
}],
execute: function () {
Object.defineProperties(Particle.prototype, { mass: {
configurable: true,
enumerable: true,
get: function () {
return 1 / this.inverseMass;
},
set: function (val) {
if (val === 0) this.inverseMass = Infinity;else this.inverseMass = 1 / val;
}
} });
Particle.prototype.destroy = function () {
return Bolt.objects.splice(Bolt.objects.indexOf(this), 1);
};
$__export("default", Particle);
}
};
});
System.register("src/lib/gravity", ["src/lib/vector"], function ($__export) {
"use strict";
var __moduleName = "src/lib/gravity";
var Vector, Gravity;
return {
setters: [function (m) {
Vector = m["default"];
}],
execute: function () {
Gravity = {
between: function (o1, o2) {
var mass = o1.mass * o2.mass;
return new Vector(Math.pow(o1.position.x - o2.position.x, 2), Math.pow(o1.position.y - o2.position.y, 2), Math.pow(o1.position.z - o2.position.z, 2));
},
globalMass: 10,
global: function (mass, g) {
return new Vector(0, mass * (g || this.globalMass), 0);
}
};
$__export("default", Gravity);
}
};
});
System.register("src/lib/frames", [], function ($__export) {
"use strict";
var __moduleName = "src/lib/frames";
var Frames;
return {
setters: [],
execute: function () {
Frames = {
lastFrame: 0,
elapsed: 0,
average: 0,
fps: 0,
tick: function (now) {
this.elapsed = (now - (this.lastFrame || now)) / 1000;
this.lastFrame = now;
if (this.elapsed > 0) this.fps = Math.round(1 / this.elapsed);
this.average = Math.round((this.average + this.fps) / 2);
return this.average;
}
};
$__export("default", Frames);
}
};
});
System.register("src/lib/play", ["src/lib/frames", "src/lib/gravity", "src/main"], function ($__export) {
"use strict";
var __moduleName = "src/lib/play";
var Frames, Gravity, Bolt, reqAnimFrame, cancelAnimFrame, Play;
return {
setters: [function (m) {
Frames = m["default"];
}, function (m) {
Gravity = m["default"];
}, function (m) {
Bolt = m["default"];
}],
execute: function () {
reqAnimFrame = requestAnimationFrame || webkitRequestAnimationFrame || mozRequestAnimationFrame || oRequestAnimationFrame || msRequestAnimationFrame, cancelAnimFrame = cancelAnimationFrame || webkitCancelAnimationFrame || mozCancelAnimationFrame || oCancelAnimationFrame || msCancelAnimationFrame;
Play = {
playing: false,
start: function (fn) {
Frames.tick(Date.now());
var canvas = typeof Bolt.configs.canvas === "function" ? Bolt.configs.canvas() : Bolt.configs.canvas;
Bolt._canvas = canvas;
var ctx = canvas.getContext("2d");
(function loop() {
reqAnimFrame(function (now) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "black";
ctx.fillRect(0, 0, canvas.width, canvas.height);
var avg = Frames.tick(now);
for (var i = 0,
len = Bolt.objects.length; i < len; i++) {
var object = Bolt.objects[i];
if (Bolt.configs.globalGravity) {
var force = Gravity.global(object.inverseMass);
object.position.add(object.velocity.clone().scalar(Frames.elapsed));
var acc = object.acceleration.clone();
acc.add(force);
object.velocity.add(acc.scalar(Frames.elapsed));
object.velocity.scalar(Math.pow(object.damping, Frames.elapsed));
ctx.beginPath();
ctx.fillStyle = object.color;
ctx.arc(object.position.x, object.position.y, object.mass, 0, 2 * Math.PI);
ctx.fill();
}
}
if (fn) fn.apply(this, arguments);
loop();
});
})();
this.playing = true;
return new Promise(function (resolve) {
setTimeout(resolve, 5);
});
},
stop: function () {
cancelAnimFrame();
this.playing = false;
}
};
$__export("default", Play);
}
};
});
System.register("src/main", ["src/lib/vector", "src/lib/particle", "src/lib/gravity", "src/lib/frames", "src/lib/play"], function ($__export) {
"use strict";
var __moduleName = "src/main";
var Vector, Particle, Gravity, Frames, Play, Bolt;
return {
setters: [function (m) {
Vector = m["default"];
}, function (m) {
Particle = m["default"];
}, function (m) {
Gravity = m["default"];
}, function (m) {
Frames = m["default"];
}, function (m) {
Play = m["default"];
}],
execute: function () {
Bolt = {
configs: {
globalGravity: true,
canvas: function () {
var canvas = document.createElement("canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);
return canvas;
}
},
config: function (o) {
for (var i in o) {
this.configs[i] = o[i];
}
return this.configs;
},
objects: [],
Vector: Vector,
Particle: Particle,
Gravity: Gravity,
Frames: Frames,
Play: Play
};
window.Bolt = Bolt;
$__export("default", Bolt);
}
};
});
});
//# sourceMappingURL=build.js.map

1
build.js.map Normal file

File diff suppressed because one or more lines are too long

9
config.js Normal file
View File

@ -0,0 +1,9 @@
System.config({
"paths": {
"*": "*.js",
"Bolt/*": "src/*.js",
"npm:*": "jspm_packages/npm/*.js",
"bolt/*": "src/*.js"
}
});

55
demos/fireworks/demo.js Normal file
View File

@ -0,0 +1,55 @@
function Firework(props) {
var particle = Bolt.Particle(props);
particle.type = props.type || 0;
particle.age = Math.random() * (5 - 3) + 3;
particle.damping = 0.93;
particle.velocity = props.velocity || Bolt.Vector.random([-8, 8], [-60, -12], [-5, 0]);
particle.color = props.color;
return particle;
}
var fireworks = [];
var count = 0;
Bolt.Play.start(function() {
count++;
if(count === 8) {
fireworks.push(new Firework({
type: 0,
position: Bolt.Vector(Bolt._canvas.width/2, Bolt._canvas.height/2, 0),
color: '#FF3636',
mass: 2
}));
count = 0;
}
for(var i = 0, len = fireworks.length; i < len; i++) {
var fw = fireworks[i];
fw.age -= Bolt.Frames.elapsed;
if(fw.age < 0) {
fw.destroy();
fireworks.splice(i, 1);
i--;
len--;
if(fw.type === 1) continue;
for(var x = 0; x < 5; x++) {
var vel = fw.velocity.clone().add(Bolt.Vector.random([-8, 8], [-10, 10], [-5, 5]));
var childFirework = new Firework({
type: 1,
position: fw.position.clone(),
velocity: vel,
color: '#FFA400',
mass: 1
});
fireworks.push(childFirework);
}
}
}
}).then(function() {
});

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bolt</title>
</head>
<body style="margin: 0">
<p style="position: absolute;top:5px;left:10px;" id='fps'></p>
<script src='../../build.js'></script>
<script src='demo.js'></script>
</body>
</html>

View File

@ -0,0 +1 @@
0.11,0.11,0.0.79

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

2
jspm_packages/system.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2253
jspm_packages/system.src.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

19
jspm_packages/traceur.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

29006
jspm_packages/traceur.src.js Normal file

File diff suppressed because one or more lines are too long

1
node_modules/.bin/watch generated vendored Symbolic link
View File

@ -0,0 +1 @@
../watch/cli.js

3
node_modules/async/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.10"

19
node_modules/async/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2010-2014 Caolan McMahon
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.

1646
node_modules/async/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

11
node_modules/async/component.json generated vendored Normal file
View File

@ -0,0 +1,11 @@
{
"name": "async",
"repo": "caolan/async",
"description": "Higher-order functions and common patterns for asynchronous code",
"version": "0.1.23",
"keywords": [],
"dependencies": {},
"development": {},
"main": "lib/async.js",
"scripts": [ "lib/async.js" ]
}

1123
node_modules/async/lib/async.js generated vendored Executable file

File diff suppressed because it is too large Load Diff

60
node_modules/async/package.json generated vendored Normal file
View File

@ -0,0 +1,60 @@
{
"name": "async",
"description": "Higher-order functions and common patterns for asynchronous code",
"main": "./lib/async",
"author": {
"name": "Caolan McMahon"
},
"version": "0.9.0",
"repository": {
"type": "git",
"url": "https://github.com/caolan/async.git"
},
"bugs": {
"url": "https://github.com/caolan/async/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/caolan/async/raw/master/LICENSE"
}
],
"devDependencies": {
"nodeunit": ">0.0.0",
"uglify-js": "1.2.x",
"nodelint": ">0.0.0"
},
"jam": {
"main": "lib/async.js",
"include": [
"lib/async.js",
"README.md",
"LICENSE"
]
},
"scripts": {
"test": "nodeunit test/test-async.js"
},
"homepage": "https://github.com/caolan/async",
"_id": "async@0.9.0",
"dist": {
"shasum": "ac3613b1da9bed1b47510bb4651b8931e47146c7",
"tarball": "http://registry.npmjs.org/async/-/async-0.9.0.tgz"
},
"_from": "async@*",
"_npmVersion": "1.4.3",
"_npmUser": {
"name": "caolan",
"email": "caolan.mcmahon@gmail.com"
},
"maintainers": [
{
"name": "caolan",
"email": "caolan@caolanmcmahon.com"
}
],
"directories": {},
"_shasum": "ac3613b1da9bed1b47510bb4651b8931e47146c7",
"_resolved": "http://registry.npmjs.org/async/-/async-0.9.0.tgz",
"readme": "ERROR: No README data found!"
}

95
node_modules/chalk/index.js generated vendored Normal file
View File

@ -0,0 +1,95 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var chalk = module.exports;
function build(_styles) {
var builder = function builder() {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
builder.__proto__ = proto;
return builder;
}
var styles = (function () {
var ret = {};
ansiStyles.grey = ansiStyles.gray;
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build(this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!chalk.enabled || !str) {
return str;
}
/*jshint validthis: true*/
var nestedStyles = this._styles;
for (var i = 0; i < nestedStyles.length; i++) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build([name]);
}
};
});
return ret;
}
defineProps(chalk, init());
chalk.styles = ansiStyles;
chalk.hasColor = hasAnsi;
chalk.stripColor = stripAnsi;
chalk.supportsColor = supportsColor;
// detect mode if not set manually
if (chalk.enabled === undefined) {
chalk.enabled = chalk.supportsColor;
}

1
node_modules/chalk/node_modules/.bin/has-ansi generated vendored Symbolic link
View File

@ -0,0 +1 @@
../has-ansi/cli.js

1
node_modules/chalk/node_modules/.bin/strip-ansi generated vendored Symbolic link
View File

@ -0,0 +1 @@
../strip-ansi/cli.js

1
node_modules/chalk/node_modules/.bin/supports-color generated vendored Symbolic link
View File

@ -0,0 +1 @@
../supports-color/cli.js

40
node_modules/chalk/node_modules/ansi-styles/index.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
'use strict';
var styles = module.exports;
var codes = {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29],
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39],
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
};
Object.keys(codes).forEach(function (key) {
var val = codes[key];
var style = styles[key] = {};
style.open = '\u001b[' + val[0] + 'm';
style.close = '\u001b[' + val[1] + 'm';
});

View File

@ -0,0 +1,74 @@
{
"name": "ansi-styles",
"version": "1.1.0",
"description": "ANSI escape codes for styling strings in the terminal",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/ansi-styles"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/ansi-styles/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-styles",
"_id": "ansi-styles@1.1.0",
"_shasum": "eaecbf66cd706882760b2f4691582b8f55d7a7de",
"_from": "ansi-styles@>=1.1.0 <2.0.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "eaecbf66cd706882760b2f4691582b8f55d7a7de",
"tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz",
"readme": "ERROR: No README data found!"
}

70
node_modules/chalk/node_modules/ansi-styles/readme.md generated vendored Normal file
View File

@ -0,0 +1,70 @@
# ansi-styles [![Build Status](https://travis-ci.org/sindresorhus/ansi-styles.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
![screenshot](screenshot.png)
## Install
```sh
$ npm install --save ansi-styles
```
## Usage
```js
var ansi = require('ansi-styles');
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### General
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Text colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,11 @@
'use strict';
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(matchOperatorsRe, '\\$&');
};

View File

@ -0,0 +1,69 @@
{
"name": "escape-string-regexp",
"version": "1.0.2",
"description": "Escape RegExp special characters",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/escape-string-regexp"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"regex",
"regexp",
"re",
"regular",
"expression",
"escape",
"string",
"str",
"special",
"characters"
],
"devDependencies": {
"mocha": "*"
},
"gitHead": "0587ee0ee03ea3fcbfa3c15cf67b47f214e20987",
"bugs": {
"url": "https://github.com/sindresorhus/escape-string-regexp/issues"
},
"homepage": "https://github.com/sindresorhus/escape-string-regexp",
"_id": "escape-string-regexp@1.0.2",
"_shasum": "4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1",
"_from": "escape-string-regexp@>=1.0.0 <2.0.0",
"_npmVersion": "1.4.23",
"_npmUser": {
"name": "jbnicolai",
"email": "jappelman@xebia.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"dist": {
"shasum": "4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1",
"tarball": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,27 @@
# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp)
> Escape RegExp special characters
## Install
```sh
$ npm install --save escape-string-regexp
```
## Usage
```js
var escapeStringRegexp = require('escape-string-regexp');
var escapedString = escapeStringRegexp('how much $ for a unicorn?');
//=> how much \$ for a unicorn\?
new RegExp(escapedString);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

53
node_modules/chalk/node_modules/has-ansi/cli.js generated vendored Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var hasAnsi = require('./');
var input = process.argv[2];
function stdin(cb) {
var ret = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
ret += data;
});
process.stdin.on('end', function () {
cb(ret);
});
}
function help() {
console.log([
pkg.description,
'',
'Usage',
' $ has-ansi <string>',
' $ echo <string> | has-ansi',
'',
'Exits with code 0 if input has ANSI escape codes and 1 if not'
].join('\n'));
}
function init(data) {
process.exit(hasAnsi(data) ? 0 : 1);
}
if (process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
if (process.stdin.isTTY) {
if (!input) {
help();
return;
}
init(input);
} else {
stdin(init);
}

4
node_modules/chalk/node_modules/has-ansi/index.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
'use strict';
var ansiRegex = require('ansi-regex');
var re = new RegExp(ansiRegex().source); // remove the `g` flag
module.exports = re.test.bind(re);

View File

@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g;
};

View File

@ -0,0 +1,79 @@
{
"name": "ansi-regex",
"version": "0.2.1",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/ansi-regex"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/ansi-regex/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-regex",
"_id": "ansi-regex@0.2.1",
"_shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"_from": "ansi-regex@>=0.2.0 <0.3.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,33 @@
# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save ansi-regex
```
## Usage
```js
var ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

85
node_modules/chalk/node_modules/has-ansi/package.json generated vendored Normal file
View File

@ -0,0 +1,85 @@
{
"name": "has-ansi",
"version": "0.1.0",
"description": "Check if a string has ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/has-ansi"
},
"bin": {
"has-ansi": "cli.js"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"cli",
"bin",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern",
"has"
],
"dependencies": {
"ansi-regex": "^0.2.0"
},
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/has-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/has-ansi",
"_id": "has-ansi@0.1.0",
"_shasum": "84f265aae8c0e6a88a12d7022894b7568894c62e",
"_from": "has-ansi@>=0.1.0 <0.2.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "84f265aae8c0e6a88a12d7022894b7568894c62e",
"tarball": "http://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz",
"readme": "ERROR: No README data found!"
}

45
node_modules/chalk/node_modules/has-ansi/readme.md generated vendored Normal file
View File

@ -0,0 +1,45 @@
# has-ansi [![Build Status](https://travis-ci.org/sindresorhus/has-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/has-ansi)
> Check if a string has [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save has-ansi
```
## Usage
```js
var hasAnsi = require('has-ansi');
hasAnsi('\u001b[4mcake\u001b[0m');
//=> true
hasAnsi('cake');
//=> false
```
## CLI
```sh
$ npm install --global has-ansi
```
```
$ has-ansi --help
Usage
$ has-ansi <string>
$ echo <string> | has-ansi
Exits with code 0 if input has ANSI escape codes and 1 if not
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

39
node_modules/chalk/node_modules/strip-ansi/cli.js generated vendored Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var pkg = require('./package.json');
var strip = require('./');
var input = process.argv[2];
function help() {
console.log([
pkg.description,
'',
'Usage',
' $ strip-ansi <input-file> > <output-file>',
' $ cat <input-file> | strip-ansi > <output-file>',
'',
'Example',
' $ strip-ansi unicorn.txt > unicorn-stripped.txt'
].join('\n'));
}
if (process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
if (input) {
process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
return;
}
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
process.stdout.write(strip(data));
});

6
node_modules/chalk/node_modules/strip-ansi/index.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
'use strict';
var ansiRegex = require('ansi-regex')();
module.exports = function (str) {
return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
};

View File

@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g;
};

View File

@ -0,0 +1,79 @@
{
"name": "ansi-regex",
"version": "0.2.1",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/ansi-regex"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/ansi-regex/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-regex",
"_id": "ansi-regex@0.2.1",
"_shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"_from": "ansi-regex@>=0.2.1 <0.3.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,33 @@
# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save ansi-regex
```
## Usage
```js
var ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,84 @@
{
"name": "strip-ansi",
"version": "0.3.0",
"description": "Strip ANSI escape codes",
"license": "MIT",
"bin": {
"strip-ansi": "cli.js"
},
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/strip-ansi"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"strip",
"trim",
"remove",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-regex": "^0.2.1"
},
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/strip-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/strip-ansi",
"_id": "strip-ansi@0.3.0",
"_shasum": "25f48ea22ca79187f3174a4db8759347bb126220",
"_from": "strip-ansi@>=0.3.0 <0.4.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "25f48ea22ca79187f3174a4db8759347bb126220",
"tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz",
"readme": "ERROR: No README data found!"
}

43
node_modules/chalk/node_modules/strip-ansi/readme.md generated vendored Normal file
View File

@ -0,0 +1,43 @@
# strip-ansi [![Build Status](https://travis-ci.org/sindresorhus/strip-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-ansi)
> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save strip-ansi
```
## Usage
```js
var stripAnsi = require('strip-ansi');
stripAnsi('\x1b[4mcake\x1b[0m');
//=> 'cake'
```
## CLI
```sh
$ npm install --global strip-ansi
```
```sh
$ strip-ansi --help
Usage
$ strip-ansi <input-file> > <output-file>
$ cat <input-file> | strip-ansi > <output-file>
Example
$ strip-ansi unicorn.txt > unicorn-stripped.txt
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

28
node_modules/chalk/node_modules/supports-color/cli.js generated vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var supportsColor = require('./');
var input = process.argv[2];
function help() {
console.log([
pkg.description,
'',
'Usage',
' $ supports-color',
'',
'Exits with code 0 if color is supported and 1 if not'
].join('\n'));
}
if (!input || process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
process.exit(supportsColor ? 0 : 1);

View File

@ -0,0 +1,32 @@
'use strict';
module.exports = (function () {
if (process.argv.indexOf('--no-color') !== -1) {
return false;
}
if (process.argv.indexOf('--color') !== -1) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();

View File

@ -0,0 +1,78 @@
{
"name": "supports-color",
"version": "0.2.0",
"description": "Detect whether a terminal supports color",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/supports-color"
},
"bin": {
"supports-color": "cli.js"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"cli",
"bin",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/supports-color/issues"
},
"homepage": "https://github.com/sindresorhus/supports-color",
"_id": "supports-color@0.2.0",
"_shasum": "d92de2694eb3f67323973d7ae3d8b55b4c22190a",
"_from": "supports-color@>=0.2.0 <0.3.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "d92de2694eb3f67323973d7ae3d8b55b4c22190a",
"tarball": "http://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,44 @@
# supports-color [![Build Status](https://travis-ci.org/sindresorhus/supports-color.svg?branch=master)](https://travis-ci.org/sindresorhus/supports-color)
> Detect whether a terminal supports color
## Install
```sh
$ npm install --save supports-color
```
## Usage
```js
var supportsColor = require('supports-color');
if (supportsColor) {
console.log('Terminal supports color');
}
```
It obeys the `--color` and `--no-color` CLI flags.
## CLI
```sh
$ npm install --global supports-color
```
```sh
$ supports-color --help
Usage
$ supports-color
# Exits with code 0 if color is supported and 1 if not
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

82
node_modules/chalk/package.json generated vendored Normal file
View File

@ -0,0 +1,82 @@
{
"name": "chalk",
"version": "0.5.1",
"description": "Terminal string styling done right. Created because the `colors` module does some really horrible things.",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/chalk"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha",
"bench": "matcha benchmark.js"
},
"files": [
"index.js"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"ansi",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^1.1.0",
"escape-string-regexp": "^1.0.0",
"has-ansi": "^0.1.0",
"strip-ansi": "^0.3.0",
"supports-color": "^0.2.0"
},
"devDependencies": {
"matcha": "^0.5.0",
"mocha": "*"
},
"gitHead": "994758f01293f1fdcf63282e9917cb9f2cfbdaac",
"bugs": {
"url": "https://github.com/sindresorhus/chalk/issues"
},
"homepage": "https://github.com/sindresorhus/chalk",
"_id": "chalk@0.5.1",
"_shasum": "663b3a648b68b55d04690d49167aa837858f2174",
"_from": "chalk@*",
"_npmVersion": "1.4.14",
"_npmUser": {
"name": "jbnicolai",
"email": "jappelman@xebia.com"
},
"dist": {
"shasum": "663b3a648b68b55d04690d49167aa837858f2174",
"tarball": "http://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz",
"readme": "ERROR: No README data found!"
}

175
node_modules/chalk/readme.md generated vendored Normal file
View File

@ -0,0 +1,175 @@
# <img width="300" src="https://cdn.rawgit.com/sindresorhus/chalk/77ae94f63ab1ac61389b190e5a59866569d1a376/logo.svg" alt="chalk">
> Terminal string styling done right
[![Build Status](https://travis-ci.org/sindresorhus/chalk.svg?branch=master)](https://travis-ci.org/sindresorhus/chalk)
![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)
[colors.js](https://github.com/Marak/colors.js) is currently the most popular string styling module, but it has serious deficiencies like extending String.prototype which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.
**Chalk is a clean and focused alternative.**
![screenshot](https://github.com/sindresorhus/ansi-styles/raw/master/screenshot.png)
## Why
- Highly performant
- Doesn't extend String.prototype
- Expressive API
- Ability to nest styles
- Clean and focused
- Auto-detects color support
- Actively maintained
- [Used by 1000+ modules](https://npmjs.org/browse/depended/chalk)
## Install
```sh
$ npm install --save chalk
```
## Usage
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
var chalk = require('chalk');
// style a string
console.log( chalk.blue('Hello world!') );
// combine styled and normal strings
console.log( chalk.blue('Hello'), 'World' + chalk.red('!') );
// compose multiple styles using the chainable API
console.log( chalk.blue.bgRed.bold('Hello world!') );
// pass in multiple arguments
console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') );
// nest styles
console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') );
// nest styles of the same type even (color, underline, background)
console.log( chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!') );
```
Easily define your own themes.
```js
var chalk = require('chalk');
var error = chalk.bold.red;
console.log(error('Error!'));
```
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
```js
var name = 'Sindre';
console.log(chalk.green('Hello %s'), name);
//=> Hello Sindre
```
## API
### chalk.`<style>[.<style>...](string, [string...])`
Example: `chalk.red.bold.underline('Hello', 'world');`
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter.
Multiple arguments will be separated by space.
### chalk.enabled
Color support is automatically detected, but you can override it.
### chalk.supportsColor
Detect whether the terminal [supports color](https://github.com/sindresorhus/supports-color).
Can be overridden by the user with the flags `--color` and `--no-color`.
Used internally and handled for you, but exposed for convenience.
### chalk.styles
Exposes the styles as [ANSI escape codes](https://github.com/sindresorhus/ansi-styles).
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with yours.
```js
var chalk = require('chalk');
console.log(chalk.styles.red);
//=> {open: '\u001b[31m', close: '\u001b[39m'}
console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close);
```
### chalk.hasColor(string)
Check whether a string [has color](https://github.com/sindresorhus/has-ansi).
### chalk.stripColor(string)
[Strip color](https://github.com/sindresorhus/strip-ansi) from a string.
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
Example:
```js
var chalk = require('chalk');
var styledString = getText();
if (!chalk.supportsColor) {
styledString = chalk.stripColor(styledString);
}
```
## Styles
### General
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Text colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

55
node_modules/watch/LICENSE generated vendored Normal file
View File

@ -0,0 +1,55 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

33
node_modules/watch/cli.js generated vendored Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env node
var argv = require('minimist')(process.argv.slice(2))
var exec = require('child_process').exec
var watch = require('./main.js')
if(argv._.length === 0) {
console.error('Usage: watch <command> [directory] [--wait=<seconds>]')
process.exit()
}
var command = argv._[0]
var dir = argv._[1] || process.cwd()
var waitTime = Number(argv.wait || argv.w)
console.error('> Watching', dir)
var wait = false
watch.watchTree(dir, function (f, curr, prev) {
if(wait) return
var run = exec(command)
run.stdout.pipe(process.stdout)
run.stderr.pipe(process.stderr)
if(waitTime > 0) {
wait = true
setTimeout(function () {
wait = false
}, waitTime * 1000)
}
})

143
node_modules/watch/main.js generated vendored Normal file
View File

@ -0,0 +1,143 @@
// Copyright 2010-2011 Mikeal Rogers
//
// 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.
var sys = require('util')
, fs = require('fs')
, path = require('path')
, events = require('events')
;
function walk (dir, options, callback) {
if (!callback) {callback = options; options = {}}
if (!callback.files) callback.files = {};
if (!callback.pending) callback.pending = 0;
callback.pending += 1;
fs.stat(dir, function (err, stat) {
if (err) return callback(err);
callback.files[dir] = stat;
fs.readdir(dir, function (err, files) {
if (err) {
if(err.code === 'EACCES' && options.ignoreUnreadableDir) return callback();
return callback(err);
}
callback.pending -= 1;
files.forEach(function (f, index) {
f = path.join(dir, f);
callback.pending += 1;
fs.stat(f, function (err, stat) {
var enoent = false
, done = false;
if (err) {
if (err.code !== 'ENOENT') {
return callback(err);
} else {
enoent = true;
}
}
callback.pending -= 1;
done = callback.pending === 0;
if (!enoent) {
if (options.ignoreDotFiles && path.basename(f)[0] === '.') return done && callback(null, callback.files);
if (options.filter && !options.filter(f, stat)) return done && callback(null, callback.files);
callback.files[f] = stat;
if (stat.isDirectory() && !(options.ignoreDirectoryPattern && options.ignoreDirectoryPattern.test(f))) walk(f, options, callback);
done = callback.pending === 0;
if (done) callback(null, callback.files);
}
})
})
if (callback.pending === 0) callback(null, callback.files);
})
if (callback.pending === 0) callback(null, callback.files);
})
}
var watchedFiles = Object.create(null);
exports.watchTree = function ( root, options, callback ) {
if (!callback) {callback = options; options = {}}
walk(root, options, function (err, files) {
if (err) throw err;
var fileWatcher = function (f) {
fs.watchFile(f, options, function (c, p) {
// Check if anything actually changed in stat
if (files[f] && !files[f].isDirectory() && c.nlink !== 0 && files[f].mtime.getTime() == c.mtime.getTime()) return;
files[f] = c;
if (!files[f].isDirectory()) callback(f, c, p);
else {
fs.readdir(f, function (err, nfiles) {
if (err) return;
nfiles.forEach(function (b) {
var file = path.join(f, b);
if (!files[file] && (options.ignoreDotFiles !== true || b[0] != '.')) {
fs.stat(file, function (err, stat) {
if (options.filter && !options.filter(file, stat)) return;
callback(file, stat, null);
files[file] = stat;
fileWatcher(file);
})
}
})
})
}
if (c.nlink === 0) {
// unwatch removed files.
delete files[f]
fs.unwatchFile(f);
}
})
}
fileWatcher(root);
for (var i in files) {
fileWatcher(i);
}
watchedFiles[root] = files;
callback(files, null, null);
})
}
exports.unwatchTree = function (root) {
if (!watchedFiles[root]) return;
Object.keys(watchedFiles[root]).forEach(fs.unwatchFile);
watchedFiles[root] = false;
};
exports.createMonitor = function (root, options, cb) {
if (!cb) {cb = options; options = {}}
var monitor = new events.EventEmitter();
monitor.stop = exports.unwatchTree.bind(null, root);
var prevFile = {file: null,action: null,stat: null};
exports.watchTree(root, options, function (f, curr, prev) {
if (typeof f == "object" && prev == null && curr === null) {
monitor.files = f;
return cb(monitor);
}
if (prev === null && (prevFile.file != f || prevFile.action != "created")) {
prevFile = { file: f, action: "created", stat: curr };
return monitor.emit("created", f, curr);
}
if (curr.nlink === 0 && (prevFile.file != f || prevFile.action != "removed")) {
prevFile = { file: f, action: "removed", stat: curr };
return monitor.emit("removed", f, curr);
}
if (prevFile.file === null || prevFile.stat.mtime.getTime() !== curr.mtime.getTime()) {
monitor.emit("changed", f, curr, prev);
}
})
}
exports.walk = walk;

4
node_modules/watch/node_modules/minimist/.travis.yml generated vendored Normal file
View File

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

18
node_modules/watch/node_modules/minimist/LICENSE generated vendored Normal file
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);

219
node_modules/watch/node_modules/minimist/index.js generated vendored Normal file
View File

@ -0,0 +1,219 @@
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { bools : {}, strings : {}, unknownFn: null };
if (typeof opts['unknown'] === 'function') {
flags.unknownFn = opts['unknown'];
}
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
flags.allBools = true;
} else {
[].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 argDefined(key, arg) {
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
flags.strings[key] || flags.bools[key] || aliases[key];
}
function setArg (key, val, arg) {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg) === false) return;
}
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], arg);
}
else if (/^--no-.+/.test(arg)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
}
else if (/^--.+/.test(arg)) {
var key = arg.match(/^--(.+)/)[1];
var next = args[i + 1];
if (next !== undefined && !/^-/.test(next)
&& !flags.bools[key]
&& !flags.allBools
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
setArg(key, next, arg);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
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, arg)
continue;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2), arg);
broken = true;
break;
}
else {
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
}
}
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], arg);
i++;
}
else if (args[i+1] && /true|false/.test(args[i+1])) {
setArg(key, args[i+1] === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
}
else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
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]);
});
}
});
if (opts['--']) {
argv['--'] = new Array();
notFlags.forEach(function(key) {
argv['--'].push(key);
});
}
else {
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);
}

70
node_modules/watch/node_modules/minimist/package.json generated vendored Normal file
View File

@ -0,0 +1,70 @@
{
"name": "minimist",
"version": "1.1.0",
"description": "parse argument options",
"main": "index.js",
"devDependencies": {
"tape": "~1.0.4",
"tap": "~0.4.0",
"covert": "^1.0.0"
},
"scripts": {
"test": "tap test/*.js",
"coverage": "covert 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"
]
},
"repository": {
"type": "git",
"url": "git://github.com/substack/minimist.git"
},
"homepage": "https://github.com/substack/minimist",
"keywords": [
"argv",
"getopt",
"parser",
"optimist"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT",
"gitHead": "e2563e462be40c344c6c65b7cde85091fe261976",
"bugs": {
"url": "https://github.com/substack/minimist/issues"
},
"_id": "minimist@1.1.0",
"_shasum": "cdf225e8898f840a258ded44fc91776770afdc93",
"_from": "minimist@>=1.1.0 <2.0.0",
"_npmVersion": "1.4.21",
"_npmUser": {
"name": "substack",
"email": "mail@substack.net"
},
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"dist": {
"shasum": "cdf225e8898f840a258ded44fc91776770afdc93",
"tarball": "http://registry.npmjs.org/minimist/-/minimist-1.1.0.tgz"
},
"directories": {},
"_resolved": "http://registry.npmjs.org/minimist/-/minimist-1.1.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,91 @@
# 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 boolean, string or array of strings to always treat as
booleans. if `true` will treat all double hyphenated arguments without equal signs
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
* `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
* `opts.stopEarly` - when true, populate `argv._` with everything after the
first non-option
* `opts['--']` - when true, populate `argv._` with everything before the `--`
and `argv['--']` with everything after the `--`. Here's an example:
* `opts.unknown` - a function which is invoked with a command line parameter not
defined in the `opts` configuration object. If the function returns `false`, the
unknown option is not added to `argv`.
```
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
{ _: [ 'one', 'two', 'three' ],
'--': [ 'four', 'five', '--six' ] }
```
Note that with `opts['--']` set, parsing for arguments still stops after the
`--`.
# install
With [npm](https://npmjs.org) do:
```
npm install minimist
```
# license
MIT

View File

@ -0,0 +1,32 @@
var parse = require('../');
var test = require('tape');
test('flag boolean true (default all --args to boolean)', function (t) {
var argv = parse(['moo', '--honk', 'cow'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});
test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
tacos: 'good',
p: '55',
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});

119
node_modules/watch/node_modules/minimist/test/bool.js generated vendored Normal file
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();
});

31
node_modules/watch/node_modules/minimist/test/dash.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
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' ] });
});
test('move arguments after the -- into their own `--` array', function(t) {
t.plan(1);
t.deepEqual(
parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }),
{ name: 'John', _: [ 'before' ], '--': [ 'after' ] });
});

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();
});

31
node_modules/watch/node_modules/minimist/test/long.js generated vendored Normal file
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();
});

36
node_modules/watch/node_modules/minimist/test/num.js generated vendored Normal file
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();
});

197
node_modules/watch/node_modules/minimist/test/parse.js generated vendored Normal file
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'] });
});

67
node_modules/watch/node_modules/minimist/test/short.js generated vendored Normal file
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,15 @@
var parse = require('../');
var test = require('tape');
test('stops parsing on the first non-option when stopEarly is set', function (t) {
var argv = parse(['--aaa', 'bbb', 'ccc', '--ddd'], {
stopEarly: true
});
t.deepEqual(argv, {
aaa: 'bbb',
_: ['ccc', '--ddd']
});
t.end();
});

View File

@ -0,0 +1,102 @@
var parse = require('../');
var test = require('tape');
test('boolean and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'true', '--derp', 'true' ];
var regular = [ '--herp', 'true', '-d', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('flag boolean true any double hyphen argument is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var argv = parse(['--honk', '--tacos=good', 'cow', '-p', '55'], {
boolean: true,
unknown: unknownFn
});
t.same(unknown, ['--tacos=good', 'cow', '-p']);
t.same(argv, {
honk: true,
_: []
});
t.end();
});
test('string and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello', '--derp', 'goodbye' ];
var regular = [ '--herp', 'hello', '-d', 'moon' ];
var opts = {
alias: { h: 'herp' },
string: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('default and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello' ];
var regular = [ '--herp', 'hello' ];
var opts = {
default: { 'h': 'bar' },
alias: { 'h': 'herp' },
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, []);
t.end();
unknownFn(); // exercise fn for 100% coverage
});
test('value following -- is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '--bad', '--', 'good', 'arg' ];
var opts = {
'--': true,
unknown: unknownFn
};
var argv = parse(aliased, opts);
t.same(unknown, ['--bad']);
t.same(argv, {
'--': ['good', 'arg'],
'_': []
})
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');
});

62
node_modules/watch/package.json generated vendored Executable file
View File

@ -0,0 +1,62 @@
{
"name": "watch",
"description": "Utilities for watching file trees.",
"tags": [
"util",
"utility",
"fs",
"files"
],
"bin": {
"watch": "./cli.js"
},
"version": "0.13.0",
"homepage": "https://github.com/mikeal/watch",
"bugs": {
"url": "https://github.com/mikeal/watch/issues"
},
"repository": {
"type": "git",
"url": "git://github.com/mikeal/watch.git"
},
"author": {
"name": "Mikeal Rogers",
"email": "mikeal.rogers@gmail.com"
},
"directories": {
"lib": "lib"
},
"engines": [
"node >=0.1.95"
],
"main": "./main",
"dependencies": {
"minimist": "^1.1.0"
},
"gitHead": "193d3b0ca432ea4650de3c728d279a64eb1ff5d1",
"_id": "watch@0.13.0",
"scripts": {},
"_shasum": "fcc6d2b3f0e8c73482eb54239a19fd5bcf9a753c",
"_from": "watch@*",
"_npmVersion": "1.4.28",
"_npmUser": {
"name": "finnpauls",
"email": "derfinn@gmail.com"
},
"maintainers": [
{
"name": "mikeal",
"email": "mikeal.rogers@gmail.com"
},
{
"name": "finnpauls",
"email": "derfinn@gmail.com"
}
],
"dist": {
"shasum": "fcc6d2b3f0e8c73482eb54239a19fd5bcf9a753c",
"tarball": "http://registry.npmjs.org/watch/-/watch-0.13.0.tgz"
},
"_resolved": "http://registry.npmjs.org/watch/-/watch-0.13.0.tgz",
"readme": "ERROR: No README data found!"
}

94
node_modules/watch/readme.mkd generated vendored Normal file
View File

@ -0,0 +1,94 @@
# watch -- Utilities for watching file trees in node.js
## Install
<pre>
npm install watch
</pre>
## Purpose
The intention of this module is provide tools that make managing the watching of file & directory trees easier.
#### watch.watchTree(root, [options,] callback)
The first argument is the directory root you want to watch.
The options object is passed to fs.watchFile but can also be used to provide two additional watchTree specific options:
* `'ignoreDotFiles'` - When true this option means that when the file tree is walked it will ignore files that being with "."
* `'filter'` - You can use this option to provide a function that returns true or false for each file and directory to decide whether or not that file/directory is included in the watcher.
* `'ignoreUnreadableDir'` - When true, this options means that when a file can't be read, this file is silently skipped.
* `'ignoreDirectoryPattern'` - When a regex pattern is set, e.g. /node_modules/, these directories are silently skipped.
The callback takes 3 arguments. The first is the file that was modified. The second is the current stat object for that file and the third is the previous stat object.
When a file is new the previous stat object is null.
When watchTree is finished walking the tree and adding all the listeners it passes the file hash (keys are the file/directory names and the values are the current stat objects) as the first argument and null as both the previous and current stat object arguments.
<pre>
watch.watchTree('/home/mikeal', function (f, curr, prev) {
if (typeof f == "object" && prev === null && curr === null) {
// Finished walking the tree
} else if (prev === null) {
// f is a new file
} else if (curr.nlink === 0) {
// f was removed
} else {
// f was changed
}
})
</pre>
### watch.unwatchTree(root)
Unwatch a previously watched directory root using `watch.watchTree`.
### watch.createMonitor(root, [options,] callback)
This function creates an EventEmitter that gives notifications for different changes that happen to the file and directory tree under the given root argument.
The options object is passed to watch.watchTree.
The callback receives the monitor object.
The monitor object contains a property, `files`, which is a hash of files and directories as keys with the current stat object as the value.
The monitor has the following events.
* `'created'` - New file has been created. Two arguments, the filename and the stat object.
* `'removed'` - A file has been moved or deleted. Two arguments, the filename and the stat object for the fd.
* `'changed'` - A file has been changed. Three arguments, the filename, the current stat object, and the previous stat object.
The monitor can be stopped using `.stop` (calls `unwatchTree`).
<pre>
var watch = require('watch')
watch.createMonitor('/home/mikeal', function (monitor) {
monitor.files['/home/mikeal/.zshrc'] // Stat object for my zshrc.
monitor.on("created", function (f, stat) {
// Handle new files
})
monitor.on("changed", function (f, curr, prev) {
// Handle file changes
})
monitor.on("removed", function (f, stat) {
// Handle removed files
})
monitor.stop(); // Stop watching
})
</pre>
### CLI
This module includes a simple command line interface, which you can install with `npm install watch -g`.
```
Usage: watch <command> [directory] [--wait=<seconds>]
```
It will watch the given directory (defaults to the current working directory) with `watchTree` and run
the given command every time a file changes. The optional `wait` parameter specifies a time in seconds
that the watching will be disabled after running a command.

3
node_modules/watch/release.sh generated vendored Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
npm version minor && npm publish && npm version patch && git push --tags && git push origin master

0
node_modules/watch/test/d/d/t generated vendored Normal file
View File

0
node_modules/watch/test/d/t generated vendored Normal file
View File

31
node_modules/watch/test/test_monitor.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
var watch = require('../main')
, assert = require('assert')
, path = require('path')
, fs = require('fs')
, target = path.join(__dirname, "d/t")
;
function clearFile() {
fs.writeFileSync(target, '')
}
clearFile()
// test if changed event is fired correctly
watch.createMonitor(__dirname, { interval: 150 },
function (monitor) {
monitor.once('changed', function (f) {
assert.equal(f, target);
clearFile();
process.exit(0)
})
fs.writeFile(target, 'Test Write\n', function (err) {
if (err) throw err;
setTimeout(function () {
// should have got the other assert done by now
assert.ok(false);
}, 300);
})
});

28
node_modules/watch/test/test_monitorRootDirectory.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
var fs, watch, watch_original;
watch = require('../main');
watch_original = require('watch');
fs = require('fs');
watch.createMonitor(__dirname, function (monitor) {
monitor.on("created", function (f, stat) {
console.log(f + " created");
});
monitor.on("changed", function (f, curr, prev) {
console.log(f + " changed");
});
monitor.on("removed", function (f, stat) {
console.log(f + " removed");
});
});
watch_original.createMonitor(__dirname, function (monitor) {
monitor.on("created", function (f, stat) {
console.log("ORIGINAL: " + f + " created");
});
monitor.on("changed", function (f, curr, prev) {
console.log("ORIGINAL: " + f + " changed");
});
monitor.on("removed", function (f, stat) {
console.log("ORIGINAL: " + f + " removed");
});
});

23
node_modules/watch/test/test_watchTree.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
var fs = require('fs')
, watch = require('../main')
, assert = require('assert')
;
//
// Demonstrate that the function of 'filter' is semantically inconsistent with
// usual convention, that returning true means 'keep this'.
//
function isDirOrQ(f, stat) { return stat.isDirectory() || f === 'Q'; }
watch.watchTree(__dirname, { filter: isDirOrQ }, function (f, curr, prev) {
if (typeof f == 'object' && prev === null && curr === null) {
Object.keys(f).forEach(function(name) {
var stat = f[name];
assert(isDirOrQ(name, stat));
});
// If the process never exits then `unwatchTree` failed to unwatch all
// the files.
watch.unwatchTree(__dirname);
}
});

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "bolt",
"version": "0.0.1",
"description": "A particle based physics engine written in ES6",
"main": "bolt.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "jspm bundle-sfx src/main",
"watch": "node watch.js"
},
"keywords": [
"physics"
],
"author": "Mahdi Dibaiee",
"license": "MIT",
"devDependencies": {
"6to5ify": "^3.1.2",
"async": "^0.9.0",
"browserify": "^8.1.1",
"chalk": "^0.5.1",
"grunt": "^0.4.5",
"grunt-6to5": "^2.0.0",
"grunt-contrib-watch": "^0.6.1",
"q": "^1.1.2",
"watch": "^0.13.0",
"watchify": "^2.2.1"
},
"jspm": {
"directories": {
"lib": "src"
}
}
}

18
src/lib/frames.js Normal file
View File

@ -0,0 +1,18 @@
var Frames = {
lastFrame: 0, // A date
elapsed: 0,
average: 0,
fps: 0,
tick: function(now) {
this.elapsed = (now - (this.lastFrame || now)) / 1000; // difference between times, converted to seconds
this.lastFrame = now;
if(this.elapsed > 0)
this.fps = Math.round(1 / this.elapsed);
this.average = Math.round((this.average + this.fps) / 2);
return this.average;
}
};
export default Frames;

19
src/lib/gravity.js Normal file
View File

@ -0,0 +1,19 @@
import Vector from './vector';
var Gravity = {
between: function(o1, o2) {
var mass = o1.mass * o2.mass;
return new Vector(
Math.pow(o1.position.x - o2.position.x, 2),
Math.pow(o1.position.y - o2.position.y, 2),
Math.pow(o1.position.z - o2.position.z, 2)
);
},
globalMass: 10,
global: function(mass, g) {
return new Vector(0, mass * (g || this.globalMass), 0);
}
};
export default Gravity;

35
src/lib/particle.js Normal file
View File

@ -0,0 +1,35 @@
import Vector from './vector';
import Bolt from '../main';
function Particle(properties = {}) {
if(!(this instanceof Particle)) return new Particle(properties);
this.position = properties.position || new Vector();
this.velocity = properties.velocity || new Vector();
this.acceleration = properties.acceleration || new Vector();
this.damping = properties.damping || 0.95;
this.mass = properties.mass || 10;
Bolt.objects.push(this);
}
Object.defineProperties(Particle.prototype, {
mass: {
configurable: true,
enumerable: true,
get: function() {
return 1 / this.inverseMass;
},
set: function(val) {
if(val === 0) this.inverseMass = Infinity;
else this.inverseMass = 1/val;
}
}
});
Particle.prototype.destroy = function() {
return Bolt.objects.splice(Bolt.objects.indexOf(this), 1);
}
export default Particle;

73
src/lib/play.js Normal file
View File

@ -0,0 +1,73 @@
import Frames from './frames';
import Gravity from './gravity';
import Bolt from '../main';
var reqAnimFrame = requestAnimationFrame ||
webkitRequestAnimationFrame ||
mozRequestAnimationFrame ||
oRequestAnimationFrame ||
msRequestAnimationFrame,
cancelAnimFrame = cancelAnimationFrame ||
webkitCancelAnimationFrame ||
mozCancelAnimationFrame ||
oCancelAnimationFrame ||
msCancelAnimationFrame;
var Play = {
playing: false,
start: function(fn) {
Frames.tick(Date.now());
var canvas = typeof Bolt.configs.canvas === 'function' ? Bolt.configs.canvas() : Bolt.configs.canvas;
Bolt._canvas = canvas;
var ctx = canvas.getContext('2d');
(function loop() {
reqAnimFrame(function(now) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, canvas.width, canvas.height);
var avg = Frames.tick(now);
for(var i = 0, len = Bolt.objects.length; i < len; i++) {
var object = Bolt.objects[i];
if(Bolt.configs.globalGravity) {
var force = Gravity.global(object.inverseMass);
object.position.add(object.velocity.clone().scalar(Frames.elapsed));
var acc = object.acceleration.clone();
acc.add(force);
object.velocity.add(acc.scalar(Frames.elapsed));
object.velocity.scalar(Math.pow(object.damping, Frames.elapsed));
ctx.beginPath();
ctx.fillStyle = object.color;
ctx.arc(object.position.x, object.position.y, object.mass, 0, 2*Math.PI);
ctx.fill();
}
}
if(fn) fn.apply(this, arguments);
loop();
});
})();
this.playing = true;
return new Promise((resolve) => {
setTimeout(resolve, 5);
});
},
stop: function() {
cancelAnimFrame();
this.playing = false;
}
};
export default Play;

94
src/lib/vector.js Normal file
View File

@ -0,0 +1,94 @@
function Vector(x = 0, y = 0, z = 0) {
if(!(this instanceof Vector)) return new Vector(x, y, z);
this.x = x;
this.y = y;
this.z = z;
return this;
}
Vector.prototype.invert = function() {
this.x = -this.x;
this.y = -this.y;
this.z = -this.z;
};
Vector.prototype.magnitude = function() {
return Math.sqrt(this.magnitude2());
};
Vector.prototype.magnitude2 = function() {
return this.x*this.x + this.y*this.y + this.z*this.z;
};
Vector.prototype.normalize = function() {
var magnitude = this.magnitude();
if(this.magnitude() <= 0) return this;
return this.scalar(1/magnitude);
};
Vector.prototype.scalar = function(n = 1) {
this.x *= n;
this.y *= n;
this.z *= n;
return this;
};
Vector.prototype.clone = function() {
return new Vector(this.x, this.y, this.z);
};
Vector.prototype.add = function(vec) {
this.x += vec.x;
this.y += vec.y;
this.z += vec.z;
return this;
};
Vector.prototype.component = function(vec) {
this.x *= vec.x;
this.y *= vec.y;
this.z *= vec.z;
return this;
};
Vector.prototype.dot = function(vec) {
return this.x*vec.x + this.y*vec.y + this.z*vec.z;
};
Vector.prototype.cross = function(vec) {
this.x = this.y*vec.z - this.z*vec.y;
this.y = this.x*vec.z - this.z*vec.x;
this.z = this.x*vec.y - this.y*vec.x;
return this;
};
Vector.orthonormal = function(v1, v2) {
var v1xv2 = v1.clone().cross(v2);
v2 = v1xv2.clone().cross(v1);
return [
v1.normalize(),
v2.normalize(),
v1xv2.normalize()
];
};
function randomRange(min, max) {
return Math.random() * (max - min) + min;
}
Vector.random = function(x, y, z) {
return new Vector(randomRange(x[0], x[1]), randomRange(y[0], y[1]), randomRange(z[0], z[1]));
};
function killNaN(a) {
if(isNaN(a)) return 0;
return a;
}
module.exports = Vector;

39
src/main.js Normal file
View File

@ -0,0 +1,39 @@
import Vector from './lib/vector';
import Particle from './lib/particle';
import Gravity from './lib/gravity';
import Frames from './lib/frames';
import Play from './lib/play';
var Bolt = {
configs: {
globalGravity: true,
canvas: function() {
var canvas = document.createElement('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);
return canvas;
}
},
config: function(o) {
for(var i in o) {
this.configs[i] = o[i];
}
return this.configs;
},
objects: [],
Vector: Vector,
Particle: Particle,
Gravity: Gravity,
Frames: Frames,
Play: Play
};
window.Bolt = Bolt;
export default Bolt;

46
watch.js Normal file
View File

@ -0,0 +1,46 @@
var watch = require('watch'),
spawn = require('child_process').spawn,
chalk = require('chalk'),
log = process.stdout.write.bind(process.stdout),
async = require('async');
var noLog = false;
function build(callback) {
return async.series([
function(next) {
var build = spawn('jspm', ['bundle-sfx', 'src/main']);
build.on('error', next);
build.on('exit', function() {
next(null);
});
build.stdout.pipe(process.stdout);
},
function(next) {
var build = spawn('6to5', ['build.js', '-o', 'build.js']);
build.on('error', next);
build.on('exit', function() {
next(null);
});
build.stdout.pipe(process.stdout);
}
], callback);
}
watch.watchTree(__dirname + '/src', function(changes) {
if(typeof changes === 'string') {
log('File Change: ' + chalk.yellow.bold(changes) + ' Building...');
} else {
log('Watching ' + chalk.yellow.bold(__dirname + '/src\n\n'));
noLog = true;
}
build(function(err) {
if(noLog) return;
if(err) {
log('\n'+chalk.red.bold('An error occured while building\njspm bundle-sfx src/main =>\n' + err + '\n'));
} else {
log(chalk.green.bold('Done!\n'));
}
});
});