Skip to content
Browse files

bin script

  • Loading branch information...
1 parent 53ab07c commit 32c51c1683352ac7c2e43a5d6beb111e650481c5 @substack committed Aug 10, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 bin/cmd.js
View
26 bin/cmd.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+var fs = require('fs');
+var split = require('../');
+var concatMap = require('concat-map');
+
+var files = process.argv.slice(2);
+if (files.length) {
+ var xs = concatMap(files, function (file) {
+ var src = fs.readFileSync(file, 'utf8');
+ return split(src);
+ });
+
+ var output = JSON.stringify(xs);
+ console.log(output);
+}
+else {
+ var data = '';
+ process.stdin.on('data', function (buf) { data += buf });
+
+ process.stdin.on('end', function () {
+ var xs = split(data);
+ console.log(JSON.stringify(xs));
+ });
+
+ process.stdin.resume();
+}

0 comments on commit 32c51c1

Please sign in to comment.
Something went wrong with that request. Please try again.