Style fix

js-version
Anton Medvedev 5 years ago
parent d283c6ec52
commit 7501e5a81b

30
fx.js

@ -1,11 +1,11 @@
'use strict' 'use strict'
const blessed = require('@medv/blessed') const blessed = require('@medv/blessed')
const stringWidth = require('string-width') const stringWidth = require('string-width')
const reopenTTY = require('reopen-tty')
const reduce = require('./reduce') const reduce = require('./reduce')
const print = require('./print') const print = require('./print')
const find = require('./find') const find = require('./find')
const config = require('./config') const config = require('./config')
const reopenTTY = require('reopen-tty');
module.exports = function start(filename, source) { module.exports = function start(filename, source) {
// Current rendered object on a screen. // Current rendered object on a screen.
@ -25,23 +25,23 @@ module.exports = function start(filename, source) {
let findGen = null let findGen = null
let currentPath = null let currentPath = null
let ttyReadStream; let ttyReadStream
let ttyWriteStream; let ttyWriteStream
reopenTTY.stdin(function(err, readStream) { reopenTTY.stdin(function (err, readStream) {
if (err) { if (err) {
throw err; throw err
} else { } else {
ttyReadStream = readStream; ttyReadStream = readStream
} }
}); })
reopenTTY.stdout(function(err, writeStream) { reopenTTY.stdout(function (err, writeStream) {
if (err) { if (err) {
throw err; throw err
} else { } else {
ttyWriteStream = writeStream; ttyWriteStream = writeStream
} }
}); })
const program = blessed.program({ const program = blessed.program({
input: ttyReadStream, input: ttyReadStream,
@ -573,7 +573,7 @@ module.exports = function start(filename, source) {
function* bfs(json) { function* bfs(json) {
const queue = [[json, '']] const queue = [[json, '']]
while(queue.length > 0) { while (queue.length > 0) {
const [v, path] = queue.shift() const [v, path] = queue.shift()
if (!v) { if (!v) {

@ -44,22 +44,11 @@ function main(input) {
let filename = 'fx' let filename = 'fx'
if (input === '') { if (input === '') {
if (args.length === 0) { if (args.length === 0 || (args.length === 1 && (args[0] === '-h' || args[0] === '--help'))) {
stderr.write(usage) stderr.write(usage)
process.exit(2) 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]) input = fs.readFileSync(args[0])
filename = path.basename(args[0]) filename = path.basename(args[0])
args = args.slice(1) args = args.slice(1)

Loading…
Cancel
Save