Skip to content

Commit

Permalink
fix(commands): fix option handling in subcommands
Browse files Browse the repository at this point in the history
Fixes #195
  • Loading branch information
evansiroky committed Apr 29, 2017
1 parent fd62a2b commit 4a3b0ca
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 11 deletions.
9 changes: 0 additions & 9 deletions bin/mastarm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

const commander = require('commander')
const path = require('path')

const mastarmVersion = require('../package.json').version

Expand All @@ -22,12 +21,4 @@ commander
'Transpile JavaScript down to ES5 with Babel'
)
.command('test [patterns...]', 'Run tests using Jest')
.option(
'-c, --config <path>',
'Path to configuration files.',
path.join(process.cwd(), '/configurations/default')
)
.option('-e, --env <environment>', 'Environment to use.')
.option('-m, --minify', 'Minify built files.')
.option('-O, --outdir <dir>', 'Publish directory', '')
.parse(process.argv)
10 changes: 10 additions & 0 deletions bin/mastarm-build
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

const path = require('path')

const commander = require('commander')

const budo = require('../lib/budo')
Expand All @@ -9,7 +11,15 @@ const logger = require('../lib/logger')
const util = require('../lib/util')

commander
.option(
'-c, --config <path>',
'Path to configuration files.',
path.join(process.cwd(), '/configurations/default')
)
.option('-e, --env <environment>', 'Environment to use.')
.option('-F, --flyle', 'Cache and serve tiles.')
.option('-m, --minify', 'Minify built files.')
.option('-O, --outdir <dir>', 'Publish directory', '')
.option('-p, --proxy <address>', 'Proxy calls through to target address.')
.option('-s, --serve', 'Serve with budo. Automatically rebuilds on changes.')
.option('-w, --watch', 'Automatically rebuild on changes.')
Expand Down
10 changes: 10 additions & 0 deletions bin/mastarm-deploy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

const path = require('path')

const commander = require('commander')
const commit = require('this-commit')()
const username = require('username')
Expand All @@ -14,6 +16,14 @@ const util = require('../lib/util')
const mastarmVersion = require('../package.json').version

commander
.option(
'-c, --config <path>',
'Path to configuration files.',
path.join(process.cwd(), '/configurations/default')
)
.option('-e, --env <environment>', 'Environment to use.')
.option('-m, --minify', 'Minify built files.')
.option('-O, --outdir <dir>', 'Publish directory', '')
.option('--cloudfront', 'CloudFront Distribution ID to invalidate.')
.option('--s3bucket', 'S3 Bucket to push to.')
.parse(process.argv)
Expand Down
10 changes: 9 additions & 1 deletion bin/mastarm-lint-messages
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env node

const path = require('path')

const commander = require('commander')

const lintMessages = require('../lib/lint-messages').lint
const loadConfig = require('../lib/load-config')
const logger = require('../lib/logger')

commander.parse(process.argv)
commander
.option(
'-c, --config <path>',
'Path to configuration files.',
path.join(process.cwd(), '/configurations/default')
)
.parse(process.argv)

const config = loadConfig(process.cwd(), commander.config, commander.env)
const paths = commander.args
Expand Down
12 changes: 11 additions & 1 deletion bin/mastarm-prepublish
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#!/usr/bin/env node

const path = require('path')

const commander = require('commander')

const loadConfig = require('../lib/load-config')
const prepublish = require('../lib/prepublish')
const util = require('../lib/util')

commander.parse(process.argv)
commander
.option(
'-c, --config <path>',
'Path to configuration files.',
path.join(process.cwd(), '/configurations/default')
)
.option('-e, --env <environment>', 'Environment to use.')
.option('-O, --outdir <dir>', 'Publish directory', '')
.parse(process.argv)

const config = loadConfig(process.cwd(), commander.config, commander.env)
const get = util.makeGetFn([commander, config.settings])
Expand Down
8 changes: 8 additions & 0 deletions bin/mastarm-test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

const path = require('path')

const commander = require('commander')
const jest = require('jest')

Expand All @@ -8,6 +10,12 @@ const jestUtils = require('../lib/jest')
const util = require('../lib/util')

commander
.option(
'-c, --config <path>',
'Path to configuration files.',
path.join(process.cwd(), '/configurations/default')
)
.option('-e, --env <environment>', 'Environment to use.')
.option(
'-u, --update-snapshots',
'Force update of snapshots. USE WITH CAUTION.'
Expand Down

0 comments on commit 4a3b0ca

Please sign in to comment.