Skip to content

Commit

Permalink
Merge pull request #150 from wking-io/www
Browse files Browse the repository at this point in the history
Adding catch for elm make --output flag being used in wrong location
  • Loading branch information
wking-io committed Nov 9, 2018
2 parents d12d142 + c097f4e commit f81638f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
30 changes: 28 additions & 2 deletions bin/elm-live.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,31 @@ program
})
.parse(process.argv)

const elmLive = require('../lib/src/elm-live')
elmLive(program, { inputStream: process.stdin, outputStream: process.stdout })
function hasBadOutput ([val, done], arg) {
if (done) {
return [val, done]
} else if (arg === '--') {
return [val, true]
}

return arg.includes('--output') ? [true, true] : [false, false]
}

const [ isBadOutput ] = program.rawArgs.reduce(hasBadOutput, [false, false])

if (isBadOutput) {
console.log(``)
console.log(chalk.red.bold(`----------------------`))
console.log(chalk.red.bold(`|| ERROR IN COMMAND ||`))
console.log(chalk.red.bold(`----------------------`))
console.log(``)
console.log(`Usage: ${chalk.blue('<elm-main> [options] [--] [elm make options]')}`)
console.log(``)
console.log(`You have used the ${chalk.blue('elm make')} flag --output in the wrong location. As seen in the usage example about, all ${chalk.blue('elm make')} flags must be added to your command after the -- separator.`)
console.log(``)
console.log(``)
console.log(``)
} else {
const elmLive = require('../lib/src/elm-live')
elmLive(program, { inputStream: process.stdin, outputStream: process.stdout })
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"files": [
"lib/index.js",
"lib/src/**/*.js",
"bin/elm-live.js"
"bin/elm-live.js",
"License.md"
],
"license": "MIT",
"keywords": [
Expand Down

0 comments on commit f81638f

Please sign in to comment.