Browse files

[fix] remove vendor/ using bundleDeps and correcting .gitignore

  • Loading branch information...
1 parent 2add277 commit 1c5e14761d42b958b6973864915fdc0d05cba74e @dominictarr dominictarr committed Oct 14, 2011
Showing with 6 additions and 2,670 deletions.
  1. +2 −1 .gitignore
  2. +0 −7 README.md
  3. +1 −1 lib/http-server.js
  4. 0 {vendor → node_modules}/node-static/LICENSE
  5. 0 {vendor → node_modules}/node-static/README.md
  6. 0 {vendor → node_modules}/node-static/benchmark/node-static-0.3.0.txt
  7. 0 {vendor → node_modules}/node-static/examples/file-server.js
  8. 0 {vendor → node_modules}/node-static/lib/node-static.js
  9. 0 {vendor → node_modules}/node-static/lib/node-static/mime.js
  10. 0 {vendor → node_modules}/node-static/lib/node-static/util.js
  11. 0 {vendor → node_modules}/node-static/package.json
  12. +3 −1 package.json
  13. +0 −19 vendor/colors/MIT-LICENSE.txt
  14. +0 −30 vendor/colors/ReadMe.md
  15. +0 −20 vendor/colors/example.html
  16. +0 −7 vendor/colors/example.js
  17. +0 −191 vendor/colors/index.js
  18. +0 −14 vendor/colors/package.json
  19. +0 −20 vendor/eyes/LICENSE
  20. +0 −4 vendor/eyes/Makefile
  21. +0 −72 vendor/eyes/README.md
  22. +0 −233 vendor/eyes/lib/eyes.js
  23. +0 −14 vendor/eyes/package.json
  24. +0 −55 vendor/eyes/test/eyes-test.js
  25. +0 −2 vendor/optimist/.gitignore
  26. +0 −4 vendor/optimist/.npmignore
  27. +0 −21 vendor/optimist/LICENSE
  28. +0 −472 vendor/optimist/README.markdown
  29. +0 −10 vendor/optimist/examples/bool.js
  30. +0 −7 vendor/optimist/examples/boolean_double.js
  31. +0 −7 vendor/optimist/examples/boolean_single.js
  32. +0 −8 vendor/optimist/examples/default_hash.js
  33. +0 −7 vendor/optimist/examples/default_singles.js
  34. +0 −8 vendor/optimist/examples/divide.js
  35. +0 −20 vendor/optimist/examples/line_count.js
  36. +0 −29 vendor/optimist/examples/line_count_options.js
  37. +0 −29 vendor/optimist/examples/line_count_wrap.js
  38. +0 −4 vendor/optimist/examples/nonopt.js
  39. +0 −2 vendor/optimist/examples/reflect.js
  40. +0 −3 vendor/optimist/examples/short.js
  41. +0 −11 vendor/optimist/examples/string.js
  42. +0 −19 vendor/optimist/examples/usage-options.js
  43. +0 −10 vendor/optimist/examples/xup.js
  44. +0 −449 vendor/optimist/index.js
  45. +0 −40 vendor/optimist/package.json
  46. +0 −66 vendor/optimist/test/_.js
  47. +0 −2 vendor/optimist/test/_/argv.js
  48. +0 −3 vendor/optimist/test/_/bin.js
  49. +0 −252 vendor/optimist/test/parse.js
  50. +0 −256 vendor/optimist/test/usage.js
  51. +0 −54 vendor/wordwrap/README.markdown
  52. +0 −10 vendor/wordwrap/example/center.js
  53. +0 −3 vendor/wordwrap/example/meat.js
  54. +0 −42 vendor/wordwrap/index.js
  55. +0 −37 vendor/wordwrap/package.json
  56. +0 −63 vendor/wordwrap/test/idleness.txt
  57. +0 −31 vendor/wordwrap/test/wrap.js
View
3 .gitignore
@@ -1,2 +1,3 @@
-node_modules
+node_modules/*
+!node_modules/node-static
npm-debug.log
View
7 README.md
@@ -14,13 +14,6 @@ Once you have `npm`:
This will install `http-server` globally so that it may be run from the command line.
-
-If you cannot install `npm`, you can always clone the source directly:
-
- git clone git://github.com/nodejitsu/http-server.git
- cd http-server
- node bin/http-server
-
## Usage:
http-server [path] [options]
View
2 lib/http-server.js
@@ -8,7 +8,7 @@
var colors = require('colors'),
argv = require('optimist').argv,
- static = require('../vendor/node-static/lib/node-static'),
+ static = require('node-static'),
http = require('http');
var HTTPServer = exports.HTTPServer = function (options) {
View
0 vendor/node-static/LICENSE → node_modules/node-static/LICENSE
File renamed without changes.
View
0 vendor/node-static/README.md → node_modules/node-static/README.md
File renamed without changes.
View
0 ...de-static/benchmark/node-static-0.3.0.txt → ...de-static/benchmark/node-static-0.3.0.txt
File renamed without changes.
View
0 vendor/node-static/examples/file-server.js → ...dules/node-static/examples/file-server.js
File renamed without changes.
View
0 vendor/node-static/lib/node-static.js → node_modules/node-static/lib/node-static.js
File renamed without changes.
View
0 vendor/node-static/lib/node-static/mime.js → ...dules/node-static/lib/node-static/mime.js
File renamed without changes.
View
0 vendor/node-static/lib/node-static/util.js → ...dules/node-static/lib/node-static/util.js
File renamed without changes.
View
0 vendor/node-static/package.json → node_modules/node-static/package.json
File renamed without changes.
View
4 package.json
@@ -17,10 +17,12 @@
"command"
],
"dependencies" : {
+ "eyes": "~0.1.6",
"colors" : "*",
"optimist" : "0.2.x"
},
- "license" : "MIT",
+ "bundleDependencies" : [ "node-static" ],
+ "license" : "MIT",
"engine" : {
"node" : ">=0.4"
}
View
19 vendor/colors/MIT-LICENSE.txt
@@ -1,19 +0,0 @@
-Copyright (c) 2010 Alexis Sellier (cloudhead) , Marak Squires
-
-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
30 vendor/colors/ReadMe.md
@@ -1,30 +0,0 @@
-<h1>colors.js - get color and style in your node.js console like what</h1>
-
-<img src="http://i.imgur.com/goJdO.png" border = "0"/>
-
- var sys = require('sys');
- var colors = require('./colors');
-
- sys.puts('hello'.green); // outputs green text
- sys.puts('i like cake and pies'.underline.red) // outputs red underlined text
- sys.puts('inverse the color'.inverse); // inverses the color
- sys.puts('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)
-
-<h2>colors and styles!</h2>
-- bold
-- italic
-- underline
-- inverse
-- yellow
-- cyan
-- white
-- magenta
-- green
-- red
-- grey
-- blue
-
-
-### Authors
-
-#### Alexis Sellier (cloudhead) , Marak Squires , Justin Campbell, Dustin Diaz (@ded)
View
20 vendor/colors/example.html
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML>
-<html lang="en-us">
- <head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>Colors Example</title>
- <script src="colors.js"></script>
- <script type="text/javascript">
- console.log('Rainbows are fun!'.rainbow);
- console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse);
- console.log('Chains are also cool.'.bold.italic.underline.red);
- </script>
- </head>
- <body>
- <script>
- document.write('Rainbows are fun!'.rainbow + '<br>');
- document.write('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse + '<br>');
- document.write('Chains are also cool.'.bold.italic.underline.red);
- </script>
- </body>
-</html>
View
7 vendor/colors/example.js
@@ -1,7 +0,0 @@
-var sys = require('sys');
-var colors = require('./colors');
-
-sys.puts('Rainbows are fun!'.rainbow);
-sys.puts('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
-sys.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
-// sys.puts('zalgo time!'.zalgo);
View
191 vendor/colors/index.js
@@ -1,191 +0,0 @@
-/*
-colors.js
-
-Copyright (c) 2010 Alexis Sellier (cloudhead) , Marak Squires
-
-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.
-
-*/
-
-// prototypes the string object to have additional method calls that add terminal colors
-var isHeadless = (typeof module !== 'undefined');
-['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'].forEach(function (style) {
-
- // __defineGetter__ at the least works in more browsers
- // http://robertnyman.com/javascript/javascript-getters-setters.html
- // Object.defineProperty only works in Chrome
- String.prototype.__defineGetter__(style, function () {
- return isHeadless ?
- stylize(this, style) : // for those running in node (headless environments)
- this.replace(/( )/, '$1'); // and for those running in browsers:
- // re: ^ you'd think 'return this' works (but doesn't) so replace coerces the string to be a real string
- });
-});
-
-// prototypes string with method "rainbow"
-// rainbow will apply a the color spectrum to a string, changing colors every letter
-String.prototype.__defineGetter__('rainbow', function () {
- if (!isHeadless) {
- return this.replace(/( )/, '$1');
- }
- var rainbowcolors = ['red','yellow','green','blue','magenta']; //RoY G BiV
- var exploded = this.split("");
- var i=0;
- exploded = exploded.map(function(letter) {
- if (letter==" ") {
- return letter;
- }
- else {
- return stylize(letter,rainbowcolors[i++ % rainbowcolors.length]);
- }
- });
- return exploded.join("");
-});
-
-function stylize(str, style) {
- var styles = {
- //styles
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- //grayscale
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [90, 39],
- //colors
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
- };
- return '\033[' + styles[style][0] + 'm' + str +
- '\033[' + styles[style][1] + 'm';
-};
-
-// don't summon zalgo
-String.prototype.__defineGetter__('zalgo', function () {
- return zalgo(this);
-});
-
-// please no
-function zalgo(text, options) {
- var soul = {
- "up" : [
- '̍','̎','̄','̅',
- '̿','̑','̆','̐',
- '͒','͗','͑','̇',
- '̈','̊','͂','̓',
- '̈','͊','͋','͌',
- '̃','̂','̌','͐',
- '̀','́','̋','̏',
- '̒','̓','̔','̽',
- '̉','ͣ','ͤ','ͥ',
- 'ͦ','ͧ','ͨ','ͩ',
- 'ͪ','ͫ','ͬ','ͭ',
- 'ͮ','ͯ','̾','͛',
- '͆','̚'
- ],
- "down" : [
- '̖','̗','̘','̙',
- '̜','̝','̞','̟',
- '̠','̤','̥','̦',
- '̩','̪','̫','̬',
- '̭','̮','̯','̰',
- '̱','̲','̳','̹',
- '̺','̻','̼','ͅ',
- '͇','͈','͉','͍',
- '͎','͓','͔','͕',
- '͖','͙','͚','̣'
- ],
- "mid" : [
- '̕','̛','̀','́',
- '͘','̡','̢','̧',
- '̨','̴','̵','̶',
- '͜','͝','͞',
- '͟','͠','͢','̸',
- '̷','͡',' ҉'
- ]
- },
- all = [].concat(soul.up, soul.down, soul.mid),
- zalgo = {};
-
- function randomNumber(range) {
- r = Math.floor(Math.random()*range);
- return r;
- };
-
- function is_char(character) {
- var bool = false;
- all.filter(function(i){
- bool = (i == character);
- });
- return bool;
- }
-
- function heComes(text, options){
- result = '';
- options = options || {};
- options["up"] = options["up"] || true;
- options["mid"] = options["mid"] || true;
- options["down"] = options["down"] || true;
- options["size"] = options["size"] || "maxi";
- var counts;
- text = text.split('');
- for(var l in text){
- if(is_char(l)) { continue; }
- result = result + text[l];
-
- counts = {"up" : 0, "down" : 0, "mid" : 0};
-
- switch(options.size) {
- case 'mini':
- counts.up = randomNumber(8);
- counts.min= randomNumber(2);
- counts.down = randomNumber(8);
- break;
- case 'maxi':
- counts.up = randomNumber(16) + 3;
- counts.min = randomNumber(4) + 1;
- counts.down = randomNumber(64) + 3;
- break;
- default:
- counts.up = randomNumber(8) + 1;
- counts.mid = randomNumber(6) / 2;
- counts.down= randomNumber(8) + 1;
- break;
- }
-
- var arr = ["up", "mid", "down"];
- for(var d in arr){
- var index = arr[d];
- for (var i = 0 ; i <= counts[index]; i++)
- {
- if(options[index]) {
- result = result + soul[index][randomNumber(soul[index].length)];
- }
- }
- }
- }
- return result;
- };
- return heComes(text);
-}
View
14 vendor/colors/package.json
@@ -1,14 +0,0 @@
-{
- "name": "colors",
- "description": "get colors in your node.js console like what",
- "version": "0.5.0",
- "author": "Marak Squires",
- "repository": {
- "type": "git",
- "url": "http://github.com/Marak/colors.js.git"
- },
- "engine": [
- "node >=0.1.90"
- ],
- "main": "colors"
-}
View
20 vendor/eyes/LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2009 cloudhead
-
-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
4 vendor/eyes/Makefile
@@ -1,4 +0,0 @@
-test:
- @@node test/eyes-test.js
-
-.PHONY: test
View
72 vendor/eyes/README.md
@@ -1,72 +0,0 @@
-eyes
-====
-
-a customizable value inspector for Node.js
-
-synopsis
---------
-
-I was tired of looking at cluttered output in the console -- something needed to be done,
-`sys.inspect()` didn't display regexps correctly, and was too verbose, and I had an hour or two to spare.
-So I decided to have some fun. _eyes_ were born.
-
-![eyes-ss](http://dl.dropbox.com/u/251849/eyes-js-ss.gif)
-
-_example of the output of a user-customized eyes.js inspector_
-
-*eyes* also deals with circular objects in an intelligent way, and can pretty-print object literals.
-
-usage
------
-
- var inspect = require('eyes').inspector({styles: {all: 'magenta'}});
-
- inspect(something); // inspect with the settings passed to `inspector`
-
-or
-
- var eyes = require('eyes');
-
- eyes.inspect(something); // inspect with the default settings
-
-you can pass a _label_ to `inspect()`, to keep track of your inspections:
-
- eyes.inspect(something, "a random value");
-
-If you want to return the output of eyes without printing it, you can set it up this way:
-
- var inspect = require('eyes').inspector({ stream: null });
-
- sys.puts(inspect({ something: 42 }));
-
-customization
--------------
-
-These are the default styles and settings used by _eyes_.
- styles: { // Styles applied to stdout
- all: 'cyan', // Overall style applied to everything
- label: 'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
- other: 'inverted', // Objects which don't have a literal representation, such as functions
- key: 'bold', // The keys in object literals, like 'a' in `{a: 1}`
-
- special: 'grey', // null, undefined...
- string: 'green',
- number: 'magenta',
- bool: 'blue', // true false
- regexp: 'green', // /\d+/
- },
- pretty: true, // Indent object literals
- hideFunctions: false, // Don't output functions at all
- stream: process.stdout, // Stream to write to, or null
- maxLength: 2048 // Truncate output if longer
-
-You can overwrite them with your own, by passing a similar object to `inspector()` or `inspect()`.
-
- var inspect = require('eyes').inspector({
- styles: {
- all: 'magenta',
- special: 'bold'
- },
- maxLength: 512
- });
-
View
233 vendor/eyes/lib/eyes.js
@@ -1,233 +0,0 @@
-//
-// Eyes.js - a customizable value inspector for Node.js
-//
-// usage:
-//
-// var inspect = require('eyes').inspector({styles: {all: 'magenta'}});
-// inspect(something); // inspect with the settings passed to `inspector`
-//
-// or
-//
-// var eyes = require('eyes');
-// eyes.inspect(something); // inspect with the default settings
-//
-var eyes = exports,
- stack = [];
-
-eyes.defaults = {
- styles: { // Styles applied to stdout
- all: 'cyan', // Overall style applied to everything
- label: 'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
- other: 'inverted', // Objects which don't have a literal representation, such as functions
- key: 'bold', // The keys in object literals, like 'a' in `{a: 1}`
- special: 'grey', // null, undefined...
- string: 'green',
- number: 'magenta',
- bool: 'blue', // true false
- regexp: 'green', // /\d+/
- },
- pretty: true, // Indent object literals
- hideFunctions: false,
- stream: process.stdout,
- maxLength: 2048 // Truncate output if longer
-};
-
-// Return a curried inspect() function, with the `options` argument filled in.
-eyes.inspector = function (options) {
- var that = this;
- return function (obj, label, opts) {
- return that.inspect.call(that, obj, label,
- merge(options || {}, opts || {}));
- };
-};
-
-// If we have a `stream` defined, use it to print a styled string,
-// if not, we just return the stringified object.
-eyes.inspect = function (obj, label, options) {
- options = merge(this.defaults, options || {});
-
- if (options.stream) {
- return this.print(stringify(obj, options), label, options);
- } else {
- return stringify(obj, options) + (options.styles ? '\033[39m' : '');
- }
-};
-
-// Output using the 'stream', and an optional label
-// Loop through `str`, and truncate it after `options.maxLength` has been reached.
-// Because escape sequences are, at this point embeded within
-// the output string, we can't measure the length of the string
-// in a useful way, without separating what is an escape sequence,
-// versus a printable character (`c`). So we resort to counting the
-// length manually.
-eyes.print = function (str, label, options) {
- for (var c = 0, i = 0; i < str.length; i++) {
- if (str.charAt(i) === '\033') { i += 4 } // `4` because '\033[25m'.length + 1 == 5
- else if (c === options.maxLength) {
- str = str.slice(0, i - 1) + '';
- break;
- } else { c++ }
- }
- return options.stream.write.call(options.stream, (label ?
- this.stylize(label, options.styles.label, options.styles) + ': ' : '') +
- this.stylize(str, options.styles.all, options.styles) + '\033[0m' + "\n");
-};
-
-// Apply a style to a string, eventually,
-// I'd like this to support passing multiple
-// styles.
-eyes.stylize = function (str, style, styles) {
- var codes = {
- 'bold' : [1, 22],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'cyan' : [36, 39],
- 'magenta' : [35, 39],
- 'blue' : [34, 39],
- 'yellow' : [33, 39],
- 'green' : [32, 39],
- 'red' : [31, 39],
- 'grey' : [90, 39]
- }, endCode;
-
- if (style && codes[style]) {
- endCode = (codes[style][1] === 39 && styles.all) ? codes[styles.all][0]
- : codes[style][1];
- return '\033[' + codes[style][0] + 'm' + str +
- '\033[' + endCode + 'm';
- } else { return str }
-};
-
-// Convert any object to a string, ready for output.
-// When an 'array' or an 'object' are encountered, they are
-// passed to specialized functions, which can then recursively call
-// stringify().
-function stringify(obj, options) {
- var that = this, stylize = function (str, style) {
- return eyes.stylize(str, options.styles[style], options.styles)
- }, index, result;
-
- if ((index = stack.indexOf(obj)) !== -1) {
- return stylize(new(Array)(stack.length - index + 1).join('.'), 'special');
- }
- stack.push(obj);
-
- result = (function (obj) {
- switch (typeOf(obj)) {
- case "string" : obj = stringifyString(obj.indexOf("'") === -1 ? "'" + obj + "'"
- : '"' + obj + '"');
- return stylize(obj, 'string');
- case "regexp" : return stylize('/' + obj.source + '/', 'regexp');
- case "number" : return stylize(obj + '', 'number');
- case "function" : return options.stream ? stylize("Function", 'other') : '[Function]';
- case "null" : return stylize("null", 'special');
- case "undefined": return stylize("undefined", 'special');
- case "boolean" : return stylize(obj + '', 'bool');
- case "date" : return stylize(obj.toUTCString());
- case "array" : return stringifyArray(obj, options, stack.length);
- case "object" : return stringifyObject(obj, options, stack.length);
- }
- })(obj);
-
- stack.pop();
- return result;
-};
-
-// Escape invisible characters in a string
-function stringifyString (str, options) {
- return str.replace(/\\/g, '\\\\')
- .replace(/\n/g, '\\n')
- .replace(/[\u0001-\u001F]/g, function (match) {
- return '\\0' + match[0].charCodeAt(0).toString(8);
- });
-}
-
-// Convert an array to a string, such as [1, 2, 3].
-// This function calls stringify() for each of the elements
-// in the array.
-function stringifyArray(ary, options, level) {
- var out = [];
- var pretty = options.pretty && (ary.length > 4 || ary.some(function (o) {
- return (typeof(o) === 'object' && Object.keys(o).length > 0) ||
- (Array.isArray(o) && o.length > 0);
- }));
- var ws = pretty ? '\n' + new(Array)(level * 4 + 1).join(' ') : ' ';
-
- for (var i = 0; i < ary.length; i++) {
- out.push(stringify(ary[i], options));
- }
-
- if (out.length === 0) {
- return '[]';
- } else {
- return '[' + ws
- + out.join(',' + (pretty ? ws : ' '))
- + (pretty ? ws.slice(0, -4) : ws) +
- ']';
- }
-};
-
-// Convert an object to a string, such as {a: 1}.
-// This function calls stringify() for each of its values,
-// and does not output functions or prototype values.
-function stringifyObject(obj, options, level) {
- var out = [];
- var pretty = options.pretty && (Object.keys(obj).length > 2 ||
- Object.keys(obj).some(function (k) { return typeof(obj[k]) === 'object' }));
- var ws = pretty ? '\n' + new(Array)(level * 4 + 1).join(' ') : ' ';
-
- Object.keys(obj).forEach(function (k) {
- if (obj.hasOwnProperty(k) && !(obj[k] instanceof Function && options.hideFunctions)) {
- out.push(eyes.stylize(k, options.styles.key, options.styles) + ': ' +
- stringify(obj[k], options));
- }
- });
-
- if (out.length === 0) {
- return '{}';
- } else {
- return "{" + ws
- + out.join(',' + (pretty ? ws : ' '))
- + (pretty ? ws.slice(0, -4) : ws) +
- "}";
- }
-};
-
-// A better `typeof`
-function typeOf(value) {
- var s = typeof(value),
- types = [Object, Array, String, RegExp, Number, Function, Boolean, Date];
-
- if (s === 'object' || s === 'function') {
- if (value) {
- types.forEach(function (t) {
- if (value instanceof t) { s = t.name.toLowerCase() }
- });
- } else { s = 'null' }
- }
- return s;
-}
-
-function merge(/* variable args */) {
- var objs = Array.prototype.slice.call(arguments);
- var target = {};
-
- objs.forEach(function (o) {
- Object.keys(o).forEach(function (k) {
- if (k === 'styles') {
- if (! o.styles) {
- target.styles = false;
- } else {
- target.styles = {}
- for (var s in o.styles) {
- target.styles[s] = o.styles[s];
- }
- }
- } else {
- target[k] = o[k];
- }
- });
- });
- return target;
-}
-
View
14 vendor/eyes/package.json
@@ -1,14 +0,0 @@
-{
- "name" : "eyes",
- "description" : "a customizable value inspector",
- "url" : "http://github.com/cloudhead/eyes.js",
- "keywords" : ["inspector", "debug", "inspect", "print"],
- "author" : "Alexis Sellier <self@cloudhead.net>",
- "contributors" : [],
- "licenses" : ["MIT"],
- "dependencies" : [],
- "main" : "./lib/eyes",
- "version" : "0.1.6",
- "directories" : { "lib": "./lib", "test": "./test" },
- "engines" : { "node": "> 0.1.90" }
-}
View
55 vendor/eyes/test/eyes-test.js
@@ -1,55 +0,0 @@
-var sys = require('sys');
-var eyes = require('../lib/eyes');
-
-eyes.inspect({
- number: 42,
- string: "John Galt",
- regexp: /[a-z]+/,
- array: [99, 168, 'x', {}],
- func: function () {},
- bool: false,
- nil: null,
- undef: undefined,
- object: {attr: []}
-}, "native types");
-
-eyes.inspect({
- number: new(Number)(42),
- string: new(String)("John Galt"),
- regexp: new(RegExp)(/[a-z]+/),
- array: new(Array)(99, 168, 'x', {}),
- bool: new(Boolean)(false),
- object: new(Object)({attr: []}),
- date: new(Date)
-}, "wrapped types");
-
-var obj = {};
-obj.that = { self: obj };
-obj.self = obj;
-
-eyes.inspect(obj, "circular object");
-eyes.inspect({hello: 'moto'}, "small object");
-eyes.inspect({hello: new(Array)(6) }, "big object");
-eyes.inspect(["hello 'world'", 'hello "world"'], "quotes");
-eyes.inspect({
- recommendations: [{
- id: 'a7a6576c2c822c8e2bd81a27e41437d8',
- key: [ 'spree', 3.764316258020699 ],
- value: {
- _id: 'a7a6576c2c822c8e2bd81a27e41437d8',
- _rev: '1-2e2d2f7fd858c4a5984bcf809d22ed98',
- type: 'domain',
- domain: 'spree',
- weight: 3.764316258020699,
- product_id: 30
- }
- }]
-}, 'complex');
-
-
-var inspect = eyes.inspector({ stream: null });
-
-sys.puts(inspect('something', "something"));
-sys.puts(inspect("something else"));
-
-sys.puts(inspect(["no color"], null, { styles: false }));
View
2 vendor/optimist/.gitignore
@@ -1,2 +0,0 @@
-node_modules/
-node_modules/*
View
4 vendor/optimist/.npmignore
@@ -1,4 +0,0 @@
-lib-cov/*
-*.swp
-*.swo
-node_modules
View
21 vendor/optimist/LICENSE
@@ -1,21 +0,0 @@
-Copyright 2010 James Halliday (mail@substack.net)
-
-This project is free software released under the MIT/X11 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
472 vendor/optimist/README.markdown
@@ -1,472 +0,0 @@
-optimist
-========
-
-Optimist is a node.js library for option parsing for people who hate option
-parsing. More specifically, this module is for people who like all the --bells
-and -whistlz of program usage but think optstrings are a waste of time.
-
-With optimist, option parsing doesn't have to suck (as much).
-
-examples
-========
-
-With Optimist, the options are just a hash! No optstrings attached.
--------------------------------------------------------------------
-
-xup.js:
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist').argv;
-
-if (argv.rif - 5 * argv.xup > 7.138) {
- console.log('Buy more riffiwobbles');
-}
-else {
- console.log('Sell the xupptumblers');
-}
-````
-
-***
-
- $ ./xup.js --rif=55 --xup=9.52
- Buy more riffiwobbles
-
- $ ./xup.js --rif 12 --xup 8.1
- Sell the xupptumblers
-
-But wait! There's more! You can do short options:
--------------------------------------------------
-
-short.js:
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist').argv;
-console.log('(%d,%d)', argv.x, argv.y);
-````
-
-***
-
- $ ./short.js -x 10 -y 21
- (10,21)
-
-And booleans, both long and short (and grouped):
-----------------------------------
-
-bool.js:
-
-````javascript
-#!/usr/bin/env node
-var util = require('util');
-var argv = require('optimist').argv;
-
-if (argv.s) {
- util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: ');
-}
-console.log(
- (argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '')
-);
-````
-
-***
-
- $ ./bool.js -s
- The cat says: meow
-
- $ ./bool.js -sp
- The cat says: meow.
-
- $ ./bool.js -sp --fr
- Le chat dit: miaou.
-
-And non-hypenated options too! Just use `argv._`!
--------------------------------------------------
-
-nonopt.js:
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist').argv;
-console.log('(%d,%d)', argv.x, argv.y);
-console.log(argv._);
-````
-
-***
-
- $ ./nonopt.js -x 6.82 -y 3.35 moo
- (6.82,3.35)
- [ 'moo' ]
-
- $ ./nonopt.js foo -x 0.54 bar -y 1.12 baz
- (0.54,1.12)
- [ 'foo', 'bar', 'baz' ]
-
-Plus, Optimist comes with .usage() and .demand()!
--------------------------------------------------
-
-divide.js:
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist')
- .usage('Usage: $0 -x [num] -y [num]')
- .demand(['x','y'])
- .argv;
-
-console.log(argv.x / argv.y);
-````
-
-***
-
- $ ./divide.js -x 55 -y 11
- 5
-
- $ node ./divide.js -x 4.91 -z 2.51
- Usage: node ./divide.js -x [num] -y [num]
-
- Options:
- -x [required]
- -y [required]
-
- Missing required arguments: y
-
-EVEN MORE HOLY COW
-------------------
-
-default_singles.js:
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist')
- .default('x', 10)
- .default('y', 10)
- .argv
-;
-console.log(argv.x + argv.y);
-````
-
-***
-
- $ ./default_singles.js -x 5
- 15
-
-default_hash.js:
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist')
- .default({ x : 10, y : 10 })
- .argv
-;
-console.log(argv.x + argv.y);
-````
-
-***
-
- $ ./default_hash.js -y 7
- 17
-
-And if you really want to get all descriptive about it...
----------------------------------------------------------
-
-boolean_single.js
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist')
- .boolean('v')
- .argv
-;
-console.dir(argv);
-````
-
-***
-
- $ ./boolean_single.js -v foo bar baz
- true
- [ 'bar', 'baz', 'foo' ]
-
-boolean_double.js
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist')
- .boolean(['x','y','z'])
- .argv
-;
-console.dir([ argv.x, argv.y, argv.z ]);
-console.dir(argv._);
-````
-
-***
-
- $ ./boolean_double.js -x -z one two three
- [ true, false, true ]
- [ 'one', 'two', 'three' ]
-
-Optimist is here to help...
----------------------------
-
-You can describe parameters for help messages and set aliases. Optimist figures
-out how to format a handy help string automatically.
-
-line_count.js
-
-````javascript
-#!/usr/bin/env node
-var argv = require('optimist')
- .usage('Count the lines in a file.\nUsage: $0')
- .demand('f')
- .alias('f', 'file')
- .describe('f', 'Load a file')
- .argv
-;
-
-var fs = require('fs');
-var s = fs.createReadStream(argv.file);
-
-var lines = 0;
-s.on('data', function (buf) {
- lines += buf.toString().match(/\n/g).length;
-});
-
-s.on('end', function () {
- console.log(lines);
-});
-````
-
-***
-
- $ node line_count.js
- Count the lines in a file.
- Usage: node ./line_count.js
-
- Options:
- -f, --file Load a file [required]
-
- Missing required arguments: f
-
- $ node line_count.js --file line_count.js
- 20
-
- $ node line_count.js -f line_count.js
- 20
-
-methods
-=======
-
-By itself,
-
-````javascript
-require('optimist').argv
-`````
-
-will use `process.argv` array to construct the `argv` object.
-
-You can pass in the `process.argv` yourself:
-
-````javascript
-require('optimist')([ '-x', '1', '-y', '2' ]).argv
-````
-
-or use .parse() to do the same thing:
-
-````javascript
-require('optimist').parse([ '-x', '1', '-y', '2' ])
-````
-
-The rest of these methods below come in just before the terminating `.argv`.
-
-.alias(key, alias)
-------------------
-
-Set key names as equivalent such that updates to a key will propagate to aliases
-and vice-versa.
-
-Optionally `.alias()` can take an object that maps keys to aliases.
-
-.default(key, value)
---------------------
-
-Set `argv[key]` to `value` if no option was specified on `process.argv`.
-
-Optionally `.default()` can take an object that maps keys to default values.
-
-.demand(key)
-------------
-
-If `key` is a string, show the usage information and exit if `key` wasn't
-specified in `process.argv`.
-
-If `key` is a number, demand at least as many non-option arguments, which show
-up in `argv._`.
-
-If `key` is an Array, demand each element.
-
-.describe(key, desc)
---------------------
-
-Describe a `key` for the generated usage information.
-
-Optionally `.describe()` can take an object that maps keys to descriptions.
-
-.options(key, opt)
-------------------
-
-Instead of chaining together `.alias().demand().default()`, you can specify
-keys in `opt` for each of the chainable methods.
-
-For example:
-
-````javascript
-var argv = require('optimist')
- .options('f', {
- alias : 'file',
- default : '/etc/passwd',
- })
- .argv
-;
-````
-
-is the same as
-
-````javascript
-var argv = require('optimist')
- .alias('f', 'file')
- .default('f', '/etc/passwd')
- .argv
-;
-````
-
-Optionally `.options()` can take an object that maps keys to `opt` parameters.
-
-.usage(message)
----------------
-
-Set a usage message to show which commands to use. Inside `message`, the string
-`$0` will get interpolated to the current script name or node command for the
-present script similar to how `$0` works in bash or perl.
-
-.check(fn)
-----------
-
-Check that certain conditions are met in the provided arguments.
-
-If `fn` throws or returns `false`, show the thrown error, usage information, and
-exit.
-
-.boolean(key)
--------------
-
-Interpret `key` as a boolean. If a non-flag option follows `key` in
-`process.argv`, that string won't get set as the value of `key`.
-
-If `key` never shows up as a flag in `process.arguments`, `argv[key]` will be
-`false`.
-
-If `key` is an Array, interpret all the elements as booleans.
-
-.string(key)
-------------
-
-Tell the parser logic not to interpret `key` as a number or boolean.
-This can be useful if you need to preserve leading zeros in an input.
-
-If `key` is an Array, interpret all the elements as strings.
-
-.wrap(columns)
---------------
-
-Format usage output to wrap at `columns` many columns.
-
-.help()
--------
-
-Return the generated usage string.
-
-.showHelp(fn=console.error)
----------------------------
-
-Print the usage data using `fn` for printing.
-
-.parse(args)
-------------
-
-Parse `args` instead of `process.argv`. Returns the `argv` object.
-
-.argv
------
-
-Get the arguments as a plain old object.
-
-Arguments without a corresponding flag show up in the `argv._` array.
-
-The script name or node command is available at `argv.$0` similarly to how `$0`
-works in bash or perl.
-
-parsing tricks
-==============
-
-stop parsing
-------------
-
-Use `--` to stop parsing flags and stuff the remainder into `argv._`.
-
- $ node examples/reflect.js -a 1 -b 2 -- -c 3 -d 4
- { _: [ '-c', '3', '-d', '4' ],
- '$0': 'node ./examples/reflect.js',
- a: 1,
- b: 2 }
-
-negate fields
--------------
-
-If you want to explicity set a field to false instead of just leaving it
-undefined or to override a default you can do `--no-key`.
-
- $ node examples/reflect.js -a --no-b
- { _: [],
- '$0': 'node ./examples/reflect.js',
- a: true,
- b: false }
-
-numbers
--------
-
-Every argument that looks like a number (`!isNaN(Number(arg))`) is converted to
-one. This way you can just `net.createConnection(argv.port)` and you can add
-numbers out of `argv` with `+` without having that mean concatenation,
-which is super frustrating.
-
-duplicates
-----------
-
-If you specify a flag multiple times it will get turned into an array containing
-all the values in order.
-
- $ node examples/reflect.js -x 5 -x 8 -x 0
- { _: [],
- '$0': 'node ./examples/reflect.js',
- x: [ 5, 8, 0 ] }
-
-installation
-============
-
-With [npm](http://github.com/isaacs/npm), just do:
- npm install optimist
-
-or clone this project on github:
-
- git clone http://github.com/substack/node-optimist.git
-
-To run the tests with [expresso](http://github.com/visionmedia/expresso),
-just do:
-
- expresso
-
-inspired By
-===========
-
-This module is loosely inspired by Perl's
-[Getopt::Casual](http://search.cpan.org/~photo/Getopt-Casual-0.13.1/Casual.pm).
View
10 vendor/optimist/examples/bool.js
@@ -1,10 +0,0 @@
-#!/usr/bin/env node
-var util = require('util');
-var argv = require('optimist').argv;
-
-if (argv.s) {
- util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: ');
-}
-console.log(
- (argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '')
-);
View
7 vendor/optimist/examples/boolean_double.js
@@ -1,7 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .boolean(['x','y','z'])
- .argv
-;
-console.dir([ argv.x, argv.y, argv.z ]);
-console.dir(argv._);
View
7 vendor/optimist/examples/boolean_single.js
@@ -1,7 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .boolean('v')
- .argv
-;
-console.dir(argv.v);
-console.dir(argv._);
View
8 vendor/optimist/examples/default_hash.js
@@ -1,8 +0,0 @@
-#!/usr/bin/env node
-
-var argv = require('optimist')
- .default({ x : 10, y : 10 })
- .argv
-;
-
-console.log(argv.x + argv.y);
View
7 vendor/optimist/examples/default_singles.js
@@ -1,7 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .default('x', 10)
- .default('y', 10)
- .argv
-;
-console.log(argv.x + argv.y);
View
8 vendor/optimist/examples/divide.js
@@ -1,8 +0,0 @@
-#!/usr/bin/env node
-
-var argv = require('optimist')
- .usage('Usage: $0 -x [num] -y [num]')
- .demand(['x','y'])
- .argv;
-
-console.log(argv.x / argv.y);
View
20 vendor/optimist/examples/line_count.js
@@ -1,20 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .usage('Count the lines in a file.\nUsage: $0')
- .demand('f')
- .alias('f', 'file')
- .describe('f', 'Load a file')
- .argv
-;
-
-var fs = require('fs');
-var s = fs.createReadStream(argv.file);
-
-var lines = 0;
-s.on('data', function (buf) {
- lines += buf.toString().match(/\n/g).length;
-});
-
-s.on('end', function () {
- console.log(lines);
-});
View
29 vendor/optimist/examples/line_count_options.js
@@ -1,29 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .usage('Count the lines in a file.\nUsage: $0')
- .options({
- file : {
- demand : true,
- alias : 'f',
- description : 'Load a file'
- },
- base : {
- alias : 'b',
- description : 'Numeric base to use for output',
- default : 10,
- },
- })
- .argv
-;
-
-var fs = require('fs');
-var s = fs.createReadStream(argv.file);
-
-var lines = 0;
-s.on('data', function (buf) {
- lines += buf.toString().match(/\n/g).length;
-});
-
-s.on('end', function () {
- console.log(lines.toString(argv.base));
-});
View
29 vendor/optimist/examples/line_count_wrap.js
@@ -1,29 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .usage('Count the lines in a file.\nUsage: $0')
- .wrap(80)
- .demand('f')
- .alias('f', [ 'file', 'filename' ])
- .describe('f',
- "Load a file. It's pretty important."
- + " Required even. So you'd better specify it."
- )
- .alias('b', 'base')
- .describe('b', 'Numeric base to display the number of lines in')
- .default('b', 10)
- .describe('x', 'Super-secret optional parameter which is secret')
- .default('x', '')
- .argv
-;
-
-var fs = require('fs');
-var s = fs.createReadStream(argv.file);
-
-var lines = 0;
-s.on('data', function (buf) {
- lines += buf.toString().match(/\n/g).length;
-});
-
-s.on('end', function () {
- console.log(lines.toString(argv.base));
-});
View
4 vendor/optimist/examples/nonopt.js
@@ -1,4 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist').argv;
-console.log('(%d,%d)', argv.x, argv.y);
-console.log(argv._);
View
2 vendor/optimist/examples/reflect.js
@@ -1,2 +0,0 @@
-#!/usr/bin/env node
-console.dir(require('optimist').argv);
View
3 vendor/optimist/examples/short.js
@@ -1,3 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist').argv;
-console.log('(%d,%d)', argv.x, argv.y);
View
11 vendor/optimist/examples/string.js
@@ -1,11 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist')
- .string('x', 'y')
- .argv
-;
-console.dir([ argv.x, argv.y ]);
-
-/* Turns off numeric coercion:
- ./node string.js -x 000123 -y 9876
- [ '000123', '9876' ]
-*/
View
19 vendor/optimist/examples/usage-options.js
@@ -1,19 +0,0 @@
-var optimist = require('./../index');
-
-var argv = optimist.usage('This is my awesome program', {
- 'about': {
- description: 'Provide some details about the author of this program',
- required: true,
- short: 'a',
- },
- 'info': {
- description: 'Provide some information about the node.js agains!!!!!!',
- boolean: true,
- short: 'i'
- }
-}).argv;
-
-optimist.showHelp();
-
-console.log('\n\nInspecting options');
-console.dir(argv);
View
10 vendor/optimist/examples/xup.js
@@ -1,10 +0,0 @@
-#!/usr/bin/env node
-var argv = require('optimist').argv;
-
-if (argv.rif - 5 * argv.xup > 7.138) {
- console.log('Buy more riffiwobbles');
-}
-else {
- console.log('Sell the xupptumblers');
-}
-
View
449 vendor/optimist/index.js
@@ -1,449 +0,0 @@
-var path = require('path');
-var wordwrap = require('wordwrap');
-
-/* Hack an instance of Argv with process.argv into Argv
- so people can do
- require('optimist')(['--beeble=1','-z','zizzle']).argv
- to parse a list of args and
- require('optimist').argv
- to get a parsed version of process.argv.
-*/
-
-var inst = Argv(process.argv.slice(2));
-Object.keys(inst).forEach(function (key) {
- Argv[key] = typeof inst[key] == 'function'
- ? inst[key].bind(inst)
- : inst[key];
-});
-
-var exports = module.exports = Argv;
-function Argv (args, cwd) {
- var self = {};
- if (!cwd) cwd = process.cwd();
-
- self.$0 = process.argv
- .slice(0,2)
- .map(function (x) {
- var b = rebase(cwd, x);
- return x.match(/^\//) && b.length < x.length
- ? b : x
- })
- .join(' ')
- ;
-
- if (process.argv[1] == process.env._) {
- self.$0 = process.env._.replace(
- path.dirname(process.execPath) + '/', ''
- );
- }
-
- var flags = { bools : {}, strings : {} };
-
- self.boolean = function (bools) {
- if (!Array.isArray(bools)) {
- bools = [].slice.call(arguments);
- }
-
- bools.forEach(function (name) {
- flags.bools[name] = true;
- });
-
- return self;
- };
-
- self.string = function (strings) {
- if (!Array.isArray(strings)) {
- strings = [].slice.call(arguments);
- }
-
- strings.forEach(function (name) {
- flags.strings[name] = true;
- });
-
- return self;
- };
-
- var aliases = {};
- self.alias = function (x, y) {
- if (typeof x === 'object') {
- Object.keys(x).forEach(function (key) {
- self.alias(key, x[key]);
- });
- }
- else if (Array.isArray(y)) {
- y.forEach(function (yy) {
- self.alias(x, yy);
- });
- }
- else {
- var zs = (aliases[x] || []).concat(aliases[y] || []).concat(x, y);
- aliases[x] = zs.filter(function (z) { return z != x });
- aliases[y] = zs.filter(function (z) { return z != y });
- }
-
- return self;
- };
-
- var demanded = {};
- self.demand = function (keys) {
- if (typeof keys == 'number') {
- if (!demanded._) demanded._ = 0;
- demanded._ += keys;
- }
- else if (Array.isArray(keys)) {
- keys.forEach(function (key) {
- self.demand(key);
- });
- }
- else {
- demanded[keys] = true;
- }
-
- return self;
- };
-
- var usage;
- self.usage = function (msg, opts) {
- if (!opts && typeof msg === 'object') {
- opts = msg;
- msg = null;
- }
-
- usage = msg;
-
- if (opts) self.options(opts);
-
- return self;
- };
-
- function fail (msg) {
- self.showHelp();
- if (msg) console.error(msg);
- process.exit(1);
- }
-
- var checks = [];
- self.check = function (f) {
- checks.push(f);
- return self;
- };
-
- var defaults = {};
- self.default = function (key, value) {
- if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
- self.default(k, key[k]);
- });
- }
- else {
- defaults[key] = value;
- }
-
- return self;
- };
-
- var descriptions = {};
- self.describe = function (key, desc) {
- if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
- self.describe(k, key[k]);
- });
- }
- else {
- descriptions[key] = desc;
- }
- return self;
- };
-
- self.parse = function (args) {
- return Argv(args).argv;
- };
-
- self.options = function (key, opt) {
- if (typeof key === 'object') {
- Object.keys(key).forEach(function (k) {
- self.options(k, key[k]);
- });
- }
- else {
- if (opt.alias) self.alias(key, opt.alias);
- if (opt.demand) self.demand(key);
- if (opt.default) self.default(key, opt.default);
-
- if (opt.boolean || opt.type === 'boolean') {
- self.boolean(key);
- }
- if (opt.string || opt.type === 'string') {
- self.string(key);
- }
-
- var desc = opt.describe || opt.description || opt.desc;
- if (desc) {
- self.describe(key, desc);
- }
- }
-
- return self;
- };
-
- var wrap = null;
- self.wrap = function (cols) {
- wrap = cols;
- return self;
- };
-
- self.showHelp = function (fn) {
- if (!fn) fn = console.error;
- fn(self.help());
- };
-
- self.help = function () {
- var keys = Object.keys(
- Object.keys(descriptions)
- .concat(Object.keys(demanded))
- .concat(Object.keys(defaults))
- .reduce(function (acc, key) {
- if (key !== '_') acc[key] = true;
- return acc;
- }, {})
- );
-
- var help = keys.length ? [ 'Options:' ] : [];
-
- if (usage) {
- help.unshift(usage.replace(/\$0/g, self.$0), '');
- }
-
- var switches = keys.reduce(function (acc, key) {
- acc[key] = [ key ].concat(aliases[key] || [])
- .map(function (sw) {
- return (sw.length > 1 ? '--' : '-') + sw
- })
- .join(', ')
- ;
- return acc;
- }, {});
-
- var switchlen = longest(Object.keys(switches).map(function (s) {
- return switches[s] || '';
- }));
-
- var desclen = longest(Object.keys(descriptions).map(function (d) {
- return descriptions[d] || '';
- }));
-
- keys.forEach(function (key) {
- var kswitch = switches[key];
- var desc = descriptions[key] || '';
-
- if (wrap) {
- desc = wordwrap(switchlen + 4, wrap)(desc)
- .slice(switchlen + 4)
- ;
- }
-
- var spadding = new Array(
- Math.max(switchlen - kswitch.length + 3, 0)
- ).join(' ');
-
- var dpadding = new Array(
- Math.max(desclen - desc.length + 1, 0)
- ).join(' ');
-
- var type = null;
-
- if (flags.bools[key]) type = '[boolean]';
- if (flags.strings[key]) type = '[string]';
-
- if (!wrap && dpadding.length > 0) {
- desc += dpadding;
- }
-
- var prelude = ' ' + kswitch + spadding;
- var extra = [
- type,
- demanded[key]
- ? '[required]'
- : null
- ,
- defaults[key] !== undefined
- ? '[default: ' + JSON.stringify(defaults[key]) + ']'
- : null
- ,
- ].filter(Boolean).join(' ');
-
- var body = [ desc, extra ].filter(Boolean).join(' ');
-
- if (wrap) {
- var dlines = desc.split('\n');
- var dlen = dlines.slice(-1)[0].length
- + (dlines.length === 1 ? prelude.length : 0)
-
- body = desc + (dlen + extra.length > wrap - 2
- ? '\n'
- + new Array(wrap - extra.length + 1).join(' ')
- + extra
- : new Array(wrap - extra.length - dlen + 1).join(' ')
- + extra
- );
- }
-
- help.push(prelude + body);
- });
-
- help.push('');
- return help.join('\n');
- };
-
- Object.defineProperty(self, 'argv', {
- get : parseArgs,
- enumerable : true,
- });
-
- function parseArgs () {
- var argv = { _ : [], $0 : self.$0 };
- Object.keys(flags.bools).forEach(function (key) {
- setArg(key, defaults[key] || false);
- });
-
- function setArg (key, val) {
- var num = Number(val);
- var value = typeof val !== 'string' || isNaN(num) ? val : num;
- if (flags.strings[key]) value = val;
-
- if (key in argv && !flags.bools[key]) {
- if (!Array.isArray(argv[key])) {
- argv[key] = [ argv[key] ];
- }
- argv[key].push(value);
- }
- else {
- argv[key] = value;
- }
-
- (aliases[key] || []).forEach(function (x) {
- argv[x] = argv[key];
- });
- }
-
- for (var i = 0; i < args.length; i++) {
- var arg = args[i];
-
- if (arg === '--') {
- argv._.push.apply(argv._, args.slice(i + 1));
- break;
- }
- else if (arg.match(/^--.+=/)) {
- var m = arg.match(/^--([^=]+)=(.*)/);
- setArg(m[1], m[2]);
- }
- else if (arg.match(/^--no-.+/)) {
- var key = arg.match(/^--no-(.+)/)[1];
- setArg(key, false);
- }
- else if (arg.match(/^--.+/)) {
- var key = arg.match(/^--(.+)/)[1];
- var next = args[i + 1];
- if (next !== undefined && !next.match(/^-/)
- && !flags.bools[key]) {
- setArg(key, next);
- i++;
- }
- else {
- setArg(key, true);
- }
- }
- else if (arg.match(/^-[^-]+/)) {
- var letters = arg.slice(1,-1).split('');
-
- var broken = false;
- for (var j = 0; j < letters.length; j++) {
- if (letters[j+1] && letters[j+1].match(/\W/)) {
- setArg(letters[j], arg.slice(j+2));
- broken = true;
- break;
- }
- else {
- setArg(letters[j], true);
- }
- }
-
- if (!broken) {
- var key = arg.slice(-1)[0];
-
- if (args[i+1] && !args[i+1].match(/^-/)
- && !flags.bools[key]) {
- setArg(key, args[i+1]);
- i++;
- }
- else {
- setArg(key, true);
- }
- }
- }
- else {
- var n = Number(arg);
- argv._.push(isNaN(n) ? arg : n);
- }
- }
-
- Object.keys(defaults).forEach(function (key) {
- if (!(key in argv)) {
- argv[key] = defaults[key];
- }
- });
-
- if (demanded._ && argv._.length < demanded._) {
- fail('Not enough non-option arguments: got '
- + argv._.length + ', need at least ' + demanded._
- );
- }
-
- var missing = [];
- Object.keys(demanded).forEach(function (key) {
- if (!argv[key]) missing.push(key);
- });
-
- if (missing.length) {
- fail('Missing required arguments: ' + missing.join(', '));
- }
-
- checks.forEach(function (f) {
- try {
- if (f(argv) === false) {
- fail('Argument check failed: ' + f.toString());
- }
- }
- catch (err) {
- fail(err)
- }
- });
-
- return argv;
- }
-
- function longest (xs) {
- return Math.max.apply(
- null,
- xs.map(function (x) { return x.length })
- );
- }
-
- return self;
-};
-
-// rebase an absolute path to a relative one with respect to a base directory
-// exported for tests
-exports.rebase = rebase;
-function rebase (base, dir) {
- var ds = path.normalize(dir).split('/').slice(1);
- var bs = path.normalize(base).split('/').slice(1);
-
- for (var i = 0; ds[i] && ds[i] == bs[i]; i++);
- ds.splice(0, i); bs.splice(0, i);
-
- var p = path.normalize(
- bs.map(function () { return '..' }).concat(ds).join('/')
- ).replace(/\/$/,'').replace(/^$/, '.');
- return p.match(/^[.\/]/) ? p : './' + p;
-};
View
40 vendor/optimist/package.json
@@ -1,40 +0,0 @@
-{
- "name" : "optimist",
- "version" : "0.2.4",
- "description" : "Light-weight option parsing with an argv hash. No optstrings attached.",
- "main" : "./index.js",
- "directories" : {
- "lib" : ".",
- "test" : "test",
- "example" : "examples"
- },
- "dependencies" : {
- "wordwrap" : ">=0.0.1 <0.1"
- },
- "devDependencies" : {
- "hashish": "0.0.x",
- "expresso" : "=0.7.x"
- },
- "repository" : {
- "type" : "git",
- "url" : "http://github.com/substack/node-optimist.git"
- },
- "keywords" : [
- "argument",
- "args",
- "option",
- "parser",
- "parsing",
- "cli",
- "command"
- ],
- "author" : {
- "name" : "James Halliday",
- "email" : "mail@substack.net",
- "url" : "http://substack.net"
- },
- "license" : "MIT/X11",
- "engine" : {
- "node" : ">=0.4"
- }
-}
View
66 vendor/optimist/test/_.js
@@ -1,66 +0,0 @@
-var spawn = require('child_process').spawn;
-var assert = require('assert');
-
-exports.dotSlashEmpty = function () {
- testCmd('./bin.js', []);
-};
-
-exports.dotSlashArgs = function () {
- testCmd('./bin.js', [ 'a', 'b', 'c' ]);
-};
-
-exports.nodeEmpty = function () {
- testCmd('node bin.js', []);
-};
-
-exports.nodeArgs = function () {
- testCmd('node bin.js', [ 'x', 'y', 'z' ]);
-};
-
-exports.whichNodeEmpty = function () {
- var which = spawn('which', ['node']);
-
- which.stdout.on('data', function (buf) {
- testCmd(buf.toString().trim() + ' bin.js', []);
- });
-
- which.stderr.on('data', function (err) {
- assert.fail(err.toString());
- });
-};
-
-exports.whichNodeArgs = function () {
- var which = spawn('which', ['node']);
-
- which.stdout.on('data', function (buf) {
- testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ]);
- });
-
- which.stderr.on('data', function (err) {
- assert.fail(err.toString());
- });
-};
-
-function testCmd (cmd, args) {
- var to = setTimeout(function () {
- assert.fail('Never got stdout data.')
- }, 5000);
-
- var oldDir = process.cwd();
- process.chdir(__dirname + '/_');
-
- var cmds = cmd.split(' ');
-
- var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String)));
- process.chdir(oldDir);
-
- bin.stderr.on('data', function (err) {
- assert.fail(err.toString());
- });
-
- bin.stdout.on('data', function (buf) {
- clearTimeout(to);
- var _ = JSON.parse(buf.toString());
- assert.eql(_.map(String), args.map(String));
- });
-}
View
2 vendor/optimist/test/_/argv.js
@@ -1,2 +0,0 @@
-#!/usr/bin/env node
-console.log(JSON.stringify(process.argv));
View
3 vendor/optimist/test/_/bin.js
@@ -1,3 +0,0 @@
-#!/usr/bin/env node
-var argv = require('../../index').argv
-console.log(JSON.stringify(argv._));
View
252 vendor/optimist/test/parse.js
@@ -1,252 +0,0 @@
-var optimist = require('../index');
-var assert = require('assert');
-
-exports['short boolean'] = function () {
- var parse = optimist.parse([ '-b' ]);
- assert.eql(parse, { b : true, _ : [], $0 : 'expresso' });
- assert.eql(typeof parse.b, 'boolean');
-};
-
-exports['long boolean'] = function () {
- assert.eql(
- optimist.parse([ '--bool' ]),
- { bool : true, _ : [], $0 : 'expresso' }
- );
-};
-
-exports.bare = function () {
- assert.eql(
- optimist.parse([ 'foo', 'bar', 'baz' ]),
- { _ : [ 'foo', 'bar', 'baz' ], $0 : 'expresso' }
- );
-};
-
-exports['short group'] = function () {
- assert.eql(