Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Murphy-Skvorzov committed Dec 5, 2014
1 parent 3195072 commit 5c8e0ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions bin/map.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
#!/usr/bin/env node

// Apply a function to each record.
var args = require('../lib/opt').fancy({filename:__filename, usage:
[ 'Usage: jline-foreach [--help|--version]'
, ' jline-foreach <cmd>...'
].join("\n")});

if (process.argv[2] === '--help') {
console.error(require('fs').readFileSync(__filename.replace(/.js$/,'.md'),{encoding:'utf8'}));
process.exit(2);
}

var codes = process.argv.slice(2).map(function(arg){
var codes = args['<cmd>'].map(function(arg){
return Function('require','record','lineNumber','line','recordNumber',arg);
});
function map(record, lineNumber, line, recordNumber){
codes.forEach(function(code){code(require, record, lineNumber, line, recordNumber);});
console.log(JSON.stringify(record));
}

process.stdout.on('error',process.exit);
console.log.apply(null,['#'].concat(process.argv));
require('./clean')(process.stdin)
.on('jline', map);

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jline",
"version": "0.0.34",
"version": "0.0.35",
"description": "Sort, grep and join files where every line is JSON.",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 5c8e0ff

Please sign in to comment.