node_task 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/node_task/index.js +28 -21
  3. data/lib/node_task/node_modules/ndjson/cli.js +23 -0
  4. data/lib/node_task/node_modules/ndjson/collaborators.md +7 -0
  5. data/lib/node_task/node_modules/ndjson/index.js +30 -0
  6. data/lib/node_task/node_modules/ndjson/node_modules/minimist/example/parse.js +2 -0
  7. data/lib/node_task/node_modules/ndjson/node_modules/minimist/index.js +236 -0
  8. data/lib/node_task/node_modules/ndjson/node_modules/minimist/package.json +71 -0
  9. data/lib/node_task/node_modules/ndjson/node_modules/minimist/readme.markdown +91 -0
  10. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/all_bool.js +32 -0
  11. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/bool.js +166 -0
  12. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/dash.js +31 -0
  13. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/default_bool.js +35 -0
  14. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/dotted.js +22 -0
  15. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/kv_short.js +16 -0
  16. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/long.js +31 -0
  17. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/num.js +36 -0
  18. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/parse.js +197 -0
  19. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/parse_modified.js +9 -0
  20. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/short.js +67 -0
  21. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/stop_early.js +15 -0
  22. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/unknown.js +102 -0
  23. data/lib/node_task/node_modules/ndjson/node_modules/minimist/test/whitespace.js +8 -0
  24. data/lib/node_task/node_modules/ndjson/node_modules/split2/README.md +74 -0
  25. data/lib/node_task/node_modules/ndjson/node_modules/split2/index.js +83 -0
  26. data/lib/node_task/node_modules/ndjson/node_modules/split2/package.json +55 -0
  27. data/lib/node_task/node_modules/ndjson/node_modules/split2/test.js +149 -0
  28. data/lib/node_task/node_modules/ndjson/node_modules/through2/README.md +132 -0
  29. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/README.md +15 -0
  30. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/duplex.js +1 -0
  31. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
  32. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
  33. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js +982 -0
  34. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js +210 -0
  35. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js +386 -0
  36. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/core-util-is/README.md +3 -0
  37. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/core-util-is/float.patch +604 -0
  38. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +107 -0
  39. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/core-util-is/package.json +53 -0
  40. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/core-util-is/util.js +106 -0
  41. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/inherits/README.md +42 -0
  42. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/inherits/inherits.js +1 -0
  43. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/inherits/inherits_browser.js +23 -0
  44. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/inherits/package.json +50 -0
  45. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/inherits/test.js +25 -0
  46. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/isarray/README.md +54 -0
  47. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/isarray/build/build.js +209 -0
  48. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/isarray/component.json +19 -0
  49. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/isarray/index.js +3 -0
  50. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/isarray/package.json +53 -0
  51. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/string_decoder/README.md +7 -0
  52. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/string_decoder/index.js +221 -0
  53. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/node_modules/string_decoder/package.json +54 -0
  54. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/package.json +70 -0
  55. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/passthrough.js +1 -0
  56. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/readable.js +8 -0
  57. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/transform.js +1 -0
  58. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/readable-stream/writable.js +1 -0
  59. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/xtend/README.md +32 -0
  60. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/xtend/immutable.js +17 -0
  61. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/xtend/mutable.js +15 -0
  62. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/xtend/package.json +88 -0
  63. data/lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/xtend/test.js +63 -0
  64. data/lib/node_task/node_modules/ndjson/node_modules/through2/package.json +65 -0
  65. data/lib/node_task/node_modules/ndjson/node_modules/through2/through2.js +96 -0
  66. data/lib/node_task/node_modules/ndjson/package.json +64 -0
  67. data/lib/node_task/node_modules/ndjson/readme.md +55 -0
  68. data/lib/node_task/node_modules/ndjson/test.js +73 -0
  69. data/lib/node_task/node_task.rb +6 -13
  70. data/lib/node_task/package.json +2 -3
  71. metadata +69 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99371ce07a364bd79a8ebd136177535137e3442a
4
- data.tar.gz: 20fb597da7f7c1de8f3e918a31d801a1a0690860
3
+ metadata.gz: 79735e5f4ab699858eef9104cf225f8e4e1a4f3e
4
+ data.tar.gz: d7bd36c0567068bcce877b3a9eb684e553d2cefa
5
5
  SHA512:
6
- metadata.gz: 3fdd69c969a45c4c8fe489d2c46b0f196b71a1e1b01cff6357d9e3dea39ac21dc9882e44127f382079ba1f6311bbc8fd299f8b53025749a82e6862fb924c8784
7
- data.tar.gz: 9606ed4cfb79ee0c791c6ed512be8adafb279d8c1ff3525f1818857d98406fb7b1c72d311805b36f3c75668002fbb76b6ba3b3abb89e7fd9effeb15c55bc44a6
6
+ metadata.gz: 27f366f9e2b2269b46eb86b6065e5cd6872924bc1299d4116b70713a04eb87f439e20025eb648cb63db301a422b9b93b5caffec0b73f1d2885010970ed117f90
7
+ data.tar.gz: cd225c6b382359ad8b550bde59043affc81f4e566d6978440844c008b0e79c8a99bee4a6411856f452b3bebe98f41f906c525110c2a9f65d72ac52aceda544e9
@@ -1,16 +1,16 @@
1
1
  var fs = require('fs')
2
2
  var path = require('path')
3
3
  var net = require('net')
4
- var winston = require('winston')
5
4
  var ndjson = require('ndjson')
6
5
 
7
6
  var workingDir = path.resolve(process.env.NODE_TASK_CWD || __dirname)
8
7
  var errorLogPath = path.join(workingDir, 'ruby_node_task-error.log')
8
+ var debugLogPath = path.join(workingDir, 'ruby_node_task-debug.log')
9
9
 
10
10
  // write pidfile
11
11
  fs.writeFileSync(path.join(workingDir, 'ruby_node_task.pid'), process.pid+'')
12
12
 
13
- var logger = makeLogger(workingDir, process.env.NODE_TASK_DEBUG)
13
+ var logger = makeLogger(debugLogPath, process.env.NODE_TASK_DEBUG_LOG)
14
14
 
15
15
  var sockPath = process.env.NODE_TASK_SOCK_PATH || makeSockPath(
16
16
  workingDir,
@@ -80,16 +80,13 @@ function onClientConnect(socket) {
80
80
  }
81
81
 
82
82
  function onUncaughtException(err) {
83
- logger.error('uncaught exception: '+err.toString(), function () {
84
- try {
85
- fs.writeFileSync(errorLogPath, err.stack)
86
- } catch (err) {
87
- return logger.error('logging error: '+err.toString(), function () {
88
- process.exit()
89
- })
90
- }
91
- process.exit()
92
- })
83
+ try {
84
+ fs.appendFileSync(errorLogPath, err.stack)
85
+ } catch (err) {}
86
+
87
+ logger.error('uncaught exception: '+formatError(err))
88
+
89
+ process.exit()
93
90
  }
94
91
 
95
92
  function onExit() {
@@ -101,15 +98,25 @@ function onExit() {
101
98
  }
102
99
  }
103
100
 
104
- function makeLogger(workingDir, debug) {
105
- return new winston.Logger({
106
- transports: [
107
- debug ? new winston.transports.File({
108
- filename: path.join(workingDir, 'ruby_node_task-debug.log'),
109
- level: 'debug',
110
- }) : new winston.transports.Console(),
111
- ],
112
- })
101
+ function makeLogger(logFilePath, debug) {
102
+ function log(level, msg) {
103
+ try {
104
+ fs.appendFileSync(logFilePath, new Date().toISOString()+' -- '+level+' -- '+msg+'\n')
105
+ } catch (e) {}
106
+ }
107
+
108
+ return {
109
+ error: function(err) {
110
+ log('error', formatError(err))
111
+ },
112
+ debug: function(msg) {
113
+ if (debug) log('debug', msg)
114
+ },
115
+ }
116
+ }
117
+
118
+ function formatError(err) {
119
+ return err && err.stack && JSON.stringify(err.stack) || err
113
120
  }
114
121
 
115
122
  // make a path for a cross platform compatible socket path
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ var fs = require('fs')
4
+ var ndjson = require('./index.js')
5
+ var minimist = require('minimist')
6
+
7
+ var args = minimist(process.argv.slice(2))
8
+
9
+ var inputStream
10
+
11
+ var first = args._[0]
12
+ if (!first) {
13
+ console.error('Usage: ndjson [input] <options>')
14
+ process.exit(1)
15
+ }
16
+
17
+ if (first === '-') inputStream = process.stdin
18
+ else inputStream = fs.createReadStream(first)
19
+
20
+ var parse = ndjson.parse(args)
21
+ var serializer = ndjson.serialize(args)
22
+
23
+ inputStream.pipe(parse).pipe(serializer).pipe(process.stdout)
@@ -0,0 +1,7 @@
1
+ ## Collaborators
2
+
3
+ ldjson-stream is only possible due to the excellent work of the following collaborators:
4
+
5
+ <table><tbody><tr><th align="left">maxogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td></tr>
6
+ <tr><th align="left">finnp</th><td><a href="https://github.com/finnp">GitHub/finnp</a></td></tr>
7
+ </tbody></table>
@@ -0,0 +1,30 @@
1
+ var through = require('through2')
2
+ var split = require('split2')
3
+ var EOL = require('os').EOL
4
+
5
+ module.exports = parse
6
+ module.exports.serialize = module.exports.stringify = serialize
7
+ module.exports.parse = parse
8
+
9
+ function parse (opts) {
10
+ opts = opts || {}
11
+ opts.strict = opts.strict !== false
12
+
13
+ function parseRow (row) {
14
+ try {
15
+ if (row) return JSON.parse(row)
16
+ } catch (e) {
17
+ if (opts.strict) {
18
+ this.emit('error', new Error('Could not parse row ' + row.slice(0, 50) + '...'))
19
+ }
20
+ }
21
+ }
22
+
23
+ return split(parseRow)
24
+ }
25
+
26
+ function serialize (opts) {
27
+ return through.obj(function(obj, enc, cb) {
28
+ cb(null, JSON.stringify(obj) + EOL)
29
+ })
30
+ }
@@ -0,0 +1,2 @@
1
+ var argv = require('../')(process.argv.slice(2));
2
+ console.dir(argv);
@@ -0,0 +1,236 @@
1
+ module.exports = function (args, opts) {
2
+ if (!opts) opts = {};
3
+
4
+ var flags = { bools : {}, strings : {}, unknownFn: null };
5
+
6
+ if (typeof opts['unknown'] === 'function') {
7
+ flags.unknownFn = opts['unknown'];
8
+ }
9
+
10
+ if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
11
+ flags.allBools = true;
12
+ } else {
13
+ [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
14
+ flags.bools[key] = true;
15
+ });
16
+ }
17
+
18
+ var aliases = {};
19
+ Object.keys(opts.alias || {}).forEach(function (key) {
20
+ aliases[key] = [].concat(opts.alias[key]);
21
+ aliases[key].forEach(function (x) {
22
+ aliases[x] = [key].concat(aliases[key].filter(function (y) {
23
+ return x !== y;
24
+ }));
25
+ });
26
+ });
27
+
28
+ [].concat(opts.string).filter(Boolean).forEach(function (key) {
29
+ flags.strings[key] = true;
30
+ if (aliases[key]) {
31
+ flags.strings[aliases[key]] = true;
32
+ }
33
+ });
34
+
35
+ var defaults = opts['default'] || {};
36
+
37
+ var argv = { _ : [] };
38
+ Object.keys(flags.bools).forEach(function (key) {
39
+ setArg(key, defaults[key] === undefined ? false : defaults[key]);
40
+ });
41
+
42
+ var notFlags = [];
43
+
44
+ if (args.indexOf('--') !== -1) {
45
+ notFlags = args.slice(args.indexOf('--')+1);
46
+ args = args.slice(0, args.indexOf('--'));
47
+ }
48
+
49
+ function argDefined(key, arg) {
50
+ return (flags.allBools && /^--[^=]+$/.test(arg)) ||
51
+ flags.strings[key] || flags.bools[key] || aliases[key];
52
+ }
53
+
54
+ function setArg (key, val, arg) {
55
+ if (arg && flags.unknownFn && !argDefined(key, arg)) {
56
+ if (flags.unknownFn(arg) === false) return;
57
+ }
58
+
59
+ var value = !flags.strings[key] && isNumber(val)
60
+ ? Number(val) : val
61
+ ;
62
+ setKey(argv, key.split('.'), value);
63
+
64
+ (aliases[key] || []).forEach(function (x) {
65
+ setKey(argv, x.split('.'), value);
66
+ });
67
+ }
68
+
69
+ function setKey (obj, keys, value) {
70
+ var o = obj;
71
+ keys.slice(0,-1).forEach(function (key) {
72
+ if (o[key] === undefined) o[key] = {};
73
+ o = o[key];
74
+ });
75
+
76
+ var key = keys[keys.length - 1];
77
+ if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
78
+ o[key] = value;
79
+ }
80
+ else if (Array.isArray(o[key])) {
81
+ o[key].push(value);
82
+ }
83
+ else {
84
+ o[key] = [ o[key], value ];
85
+ }
86
+ }
87
+
88
+ function aliasIsBoolean(key) {
89
+ return aliases[key].some(function (x) {
90
+ return flags.bools[x];
91
+ });
92
+ }
93
+
94
+ for (var i = 0; i < args.length; i++) {
95
+ var arg = args[i];
96
+
97
+ if (/^--.+=/.test(arg)) {
98
+ // Using [\s\S] instead of . because js doesn't support the
99
+ // 'dotall' regex modifier. See:
100
+ // http://stackoverflow.com/a/1068308/13216
101
+ var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
102
+ var key = m[1];
103
+ var value = m[2];
104
+ if (flags.bools[key]) {
105
+ value = value !== 'false';
106
+ }
107
+ setArg(key, value, arg);
108
+ }
109
+ else if (/^--no-.+/.test(arg)) {
110
+ var key = arg.match(/^--no-(.+)/)[1];
111
+ setArg(key, false, arg);
112
+ }
113
+ else if (/^--.+/.test(arg)) {
114
+ var key = arg.match(/^--(.+)/)[1];
115
+ var next = args[i + 1];
116
+ if (next !== undefined && !/^-/.test(next)
117
+ && !flags.bools[key]
118
+ && !flags.allBools
119
+ && (aliases[key] ? !aliasIsBoolean(key) : true)) {
120
+ setArg(key, next, arg);
121
+ i++;
122
+ }
123
+ else if (/^(true|false)$/.test(next)) {
124
+ setArg(key, next === 'true', arg);
125
+ i++;
126
+ }
127
+ else {
128
+ setArg(key, flags.strings[key] ? '' : true, arg);
129
+ }
130
+ }
131
+ else if (/^-[^-]+/.test(arg)) {
132
+ var letters = arg.slice(1,-1).split('');
133
+
134
+ var broken = false;
135
+ for (var j = 0; j < letters.length; j++) {
136
+ var next = arg.slice(j+2);
137
+
138
+ if (next === '-') {
139
+ setArg(letters[j], next, arg)
140
+ continue;
141
+ }
142
+
143
+ if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
144
+ setArg(letters[j], next.split('=')[1], arg);
145
+ broken = true;
146
+ break;
147
+ }
148
+
149
+ if (/[A-Za-z]/.test(letters[j])
150
+ && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
151
+ setArg(letters[j], next, arg);
152
+ broken = true;
153
+ break;
154
+ }
155
+
156
+ if (letters[j+1] && letters[j+1].match(/\W/)) {
157
+ setArg(letters[j], arg.slice(j+2), arg);
158
+ broken = true;
159
+ break;
160
+ }
161
+ else {
162
+ setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
163
+ }
164
+ }
165
+
166
+ var key = arg.slice(-1)[0];
167
+ if (!broken && key !== '-') {
168
+ if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
169
+ && !flags.bools[key]
170
+ && (aliases[key] ? !aliasIsBoolean(key) : true)) {
171
+ setArg(key, args[i+1], arg);
172
+ i++;
173
+ }
174
+ else if (args[i+1] && /true|false/.test(args[i+1])) {
175
+ setArg(key, args[i+1] === 'true', arg);
176
+ i++;
177
+ }
178
+ else {
179
+ setArg(key, flags.strings[key] ? '' : true, arg);
180
+ }
181
+ }
182
+ }
183
+ else {
184
+ if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
185
+ argv._.push(
186
+ flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
187
+ );
188
+ }
189
+ if (opts.stopEarly) {
190
+ argv._.push.apply(argv._, args.slice(i + 1));
191
+ break;
192
+ }
193
+ }
194
+ }
195
+
196
+ Object.keys(defaults).forEach(function (key) {
197
+ if (!hasKey(argv, key.split('.'))) {
198
+ setKey(argv, key.split('.'), defaults[key]);
199
+
200
+ (aliases[key] || []).forEach(function (x) {
201
+ setKey(argv, x.split('.'), defaults[key]);
202
+ });
203
+ }
204
+ });
205
+
206
+ if (opts['--']) {
207
+ argv['--'] = new Array();
208
+ notFlags.forEach(function(key) {
209
+ argv['--'].push(key);
210
+ });
211
+ }
212
+ else {
213
+ notFlags.forEach(function(key) {
214
+ argv._.push(key);
215
+ });
216
+ }
217
+
218
+ return argv;
219
+ };
220
+
221
+ function hasKey (obj, keys) {
222
+ var o = obj;
223
+ keys.slice(0,-1).forEach(function (key) {
224
+ o = (o[key] || {});
225
+ });
226
+
227
+ var key = keys[keys.length - 1];
228
+ return key in o;
229
+ }
230
+
231
+ function isNumber (x) {
232
+ if (typeof x === 'number') return true;
233
+ if (/^0x[0-9a-f]+$/i.test(x)) return true;
234
+ return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
235
+ }
236
+
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "minimist",
3
+ "version": "1.2.0",
4
+ "description": "parse argument options",
5
+ "main": "index.js",
6
+ "devDependencies": {
7
+ "covert": "^1.0.0",
8
+ "tap": "~0.4.0",
9
+ "tape": "^3.5.0"
10
+ },
11
+ "scripts": {
12
+ "test": "tap test/*.js",
13
+ "coverage": "covert test/*.js"
14
+ },
15
+ "testling": {
16
+ "files": "test/*.js",
17
+ "browsers": [
18
+ "ie/6..latest",
19
+ "ff/5",
20
+ "firefox/latest",
21
+ "chrome/10",
22
+ "chrome/latest",
23
+ "safari/5.1",
24
+ "safari/latest",
25
+ "opera/12"
26
+ ]
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git://github.com/substack/minimist.git"
31
+ },
32
+ "homepage": "https://github.com/substack/minimist",
33
+ "keywords": [
34
+ "argv",
35
+ "getopt",
36
+ "parser",
37
+ "optimist"
38
+ ],
39
+ "author": {
40
+ "name": "James Halliday",
41
+ "email": "mail@substack.net",
42
+ "url": "http://substack.net"
43
+ },
44
+ "license": "MIT",
45
+ "gitHead": "dc624482fcfec5bc669c68cdb861f00573ed4e64",
46
+ "bugs": {
47
+ "url": "https://github.com/substack/minimist/issues"
48
+ },
49
+ "_id": "minimist@1.2.0",
50
+ "_shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
51
+ "_from": "minimist@>=1.2.0 <2.0.0",
52
+ "_npmVersion": "3.2.2",
53
+ "_nodeVersion": "2.4.0",
54
+ "_npmUser": {
55
+ "name": "substack",
56
+ "email": "substack@gmail.com"
57
+ },
58
+ "dist": {
59
+ "shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
60
+ "tarball": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz"
61
+ },
62
+ "maintainers": [
63
+ {
64
+ "name": "substack",
65
+ "email": "mail@substack.net"
66
+ }
67
+ ],
68
+ "directories": {},
69
+ "_resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
70
+ "readme": "ERROR: No README data found!"
71
+ }
@@ -0,0 +1,91 @@
1
+ # minimist
2
+
3
+ parse argument options
4
+
5
+ This module is the guts of optimist's argument parser without all the
6
+ fanciful decoration.
7
+
8
+ [![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)
9
+
10
+ [![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist)
11
+
12
+ # example
13
+
14
+ ``` js
15
+ var argv = require('minimist')(process.argv.slice(2));
16
+ console.dir(argv);
17
+ ```
18
+
19
+ ```
20
+ $ node example/parse.js -a beep -b boop
21
+ { _: [], a: 'beep', b: 'boop' }
22
+ ```
23
+
24
+ ```
25
+ $ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
26
+ { _: [ 'foo', 'bar', 'baz' ],
27
+ x: 3,
28
+ y: 4,
29
+ n: 5,
30
+ a: true,
31
+ b: true,
32
+ c: true,
33
+ beep: 'boop' }
34
+ ```
35
+
36
+ # methods
37
+
38
+ ``` js
39
+ var parseArgs = require('minimist')
40
+ ```
41
+
42
+ ## var argv = parseArgs(args, opts={})
43
+
44
+ Return an argument object `argv` populated with the array arguments from `args`.
45
+
46
+ `argv._` contains all the arguments that didn't have an option associated with
47
+ them.
48
+
49
+ Numeric-looking arguments will be returned as numbers unless `opts.string` or
50
+ `opts.boolean` is set for that argument name.
51
+
52
+ Any arguments after `'--'` will not be parsed and will end up in `argv._`.
53
+
54
+ options can be:
55
+
56
+ * `opts.string` - a string or array of strings argument names to always treat as
57
+ strings
58
+ * `opts.boolean` - a boolean, string or array of strings to always treat as
59
+ booleans. if `true` will treat all double hyphenated arguments without equal signs
60
+ as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
61
+ * `opts.alias` - an object mapping string names to strings or arrays of string
62
+ argument names to use as aliases
63
+ * `opts.default` - an object mapping string argument names to default values
64
+ * `opts.stopEarly` - when true, populate `argv._` with everything after the
65
+ first non-option
66
+ * `opts['--']` - when true, populate `argv._` with everything before the `--`
67
+ and `argv['--']` with everything after the `--`. Here's an example:
68
+ * `opts.unknown` - a function which is invoked with a command line parameter not
69
+ defined in the `opts` configuration object. If the function returns `false`, the
70
+ unknown option is not added to `argv`.
71
+
72
+ ```
73
+ > require('./')('one two three -- four five --six'.split(' '), { '--': true })
74
+ { _: [ 'one', 'two', 'three' ],
75
+ '--': [ 'four', 'five', '--six' ] }
76
+ ```
77
+
78
+ Note that with `opts['--']` set, parsing for arguments still stops after the
79
+ `--`.
80
+
81
+ # install
82
+
83
+ With [npm](https://npmjs.org) do:
84
+
85
+ ```
86
+ npm install minimist
87
+ ```
88
+
89
+ # license
90
+
91
+ MIT
@@ -0,0 +1,32 @@
1
+ var parse = require('../');
2
+ var test = require('tape');
3
+
4
+ test('flag boolean true (default all --args to boolean)', function (t) {
5
+ var argv = parse(['moo', '--honk', 'cow'], {
6
+ boolean: true
7
+ });
8
+
9
+ t.deepEqual(argv, {
10
+ honk: true,
11
+ _: ['moo', 'cow']
12
+ });
13
+
14
+ t.deepEqual(typeof argv.honk, 'boolean');
15
+ t.end();
16
+ });
17
+
18
+ test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
19
+ var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
20
+ boolean: true
21
+ });
22
+
23
+ t.deepEqual(argv, {
24
+ honk: true,
25
+ tacos: 'good',
26
+ p: 55,
27
+ _: ['moo', 'cow']
28
+ });
29
+
30
+ t.deepEqual(typeof argv.honk, 'boolean');
31
+ t.end();
32
+ });