Navigation Menu

Skip to content

Commit

Permalink
tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielFGray committed Sep 4, 2017
1 parent f050374 commit bb8aa61
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions index.js
Expand Up @@ -8,25 +8,23 @@ const R = require('ramda')

const isString = R.is(String)
const jsonTo = R.flip(transformJsonTypes)
const jsonToFlow = jsonTo('flow')
const jsonToTS = jsonTo('typescript')
const jsonToFlow = jsonTo({ lang: 'flow' })
const jsonToTS = jsonTo({ lang: 'typescript' })
const jsonToProptypes = x => transform(x, { plugins: [babelJsonToProptypes] }).code + "\n"

program
.option('-t, --to <output>', 'set output format', /^(flow|typescript|proptypes)$/)
.option('-t, --to <output>', 'set output format', /^(flow|typescript|proptypes|scala|rust)$/i)
.parse(process.argv)

if (! isString(program.to)) {
console.error('not a valid transformer, must be "flow", "typescript", or "proptypes"')
process.exit(1)
}

getStdin().then(i => {
const transformer = R.prop(program.to, {
getStdin().then(R.prop(program.to.toLowerCase(), {
flow: jsonToFlow,
typescript: jsonToTS,
proptypes: jsonToProptypes,
})
process.stdout.write(transformer(i))
})
}))
.then(x => process.stdout.write(x))
.catch(e => { console.error(e); process.exit(1) })

0 comments on commit bb8aa61

Please sign in to comment.