diff --git a/fx.js b/fx.js index 6278453..b267d23 100644 --- a/fx.js +++ b/fx.js @@ -1,11 +1,11 @@ 'use strict' const blessed = require('@medv/blessed') const stringWidth = require('string-width') +const reopenTTY = require('reopen-tty') const reduce = require('./reduce') const print = require('./print') const find = require('./find') const config = require('./config') -const reopenTTY = require('reopen-tty'); module.exports = function start(filename, source) { // Current rendered object on a screen. @@ -25,23 +25,23 @@ module.exports = function start(filename, source) { let findGen = null let currentPath = null - let ttyReadStream; - let ttyWriteStream; - reopenTTY.stdin(function(err, readStream) { + let ttyReadStream + let ttyWriteStream + reopenTTY.stdin(function (err, readStream) { if (err) { - throw err; + throw err } else { - ttyReadStream = readStream; - } - }); - - reopenTTY.stdout(function(err, writeStream) { + ttyReadStream = readStream + } + }) + + reopenTTY.stdout(function (err, writeStream) { if (err) { - throw err; + throw err } else { - ttyWriteStream = writeStream; - } - }); + ttyWriteStream = writeStream + } + }) const program = blessed.program({ input: ttyReadStream, @@ -573,7 +573,7 @@ module.exports = function start(filename, source) { function* bfs(json) { const queue = [[json, '']] - while(queue.length > 0) { + while (queue.length > 0) { const [v, path] = queue.shift() if (!v) { diff --git a/index.js b/index.js index 3e2b171..7b5b714 100755 --- a/index.js +++ b/index.js @@ -44,22 +44,11 @@ function main(input) { let filename = 'fx' if (input === '') { - if (args.length === 0) { + if (args.length === 0 || (args.length === 1 && (args[0] === '-h' || args[0] === '--help'))) { stderr.write(usage) process.exit(2) } - if(args[0].startsWith('-')) { - if(args[0].endsWith('h')) { - stderr.write(usage) - process.exit(2) - } - } - if(args[0].startsWith('--')) { - if(args[0].endsWith('help')) { - stderr.write(usage) - process.exit(2) - } - } + input = fs.readFileSync(args[0]) filename = path.basename(args[0]) args = args.slice(1)