Skip to content

Commit

Permalink
feat(dependencies): Check dependencies by default
Browse files Browse the repository at this point in the history
closes #19
  • Loading branch information
trevorgerhardt committed Jun 27, 2016
1 parent 69c9e52 commit 83a63fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ Entries are in the format `input/file.js:output/file.js`. Not all options pertai
```shell
$ mastarm --help

Usage: mastarm <cmd> [options]
Usage: mastarm <cmd> [options]


Commands:
Commands:

build [entries...] Bundle JavaScript & CSS
commit Force intelligent commit messages
deploy [options] [entries...] Bundle & Deploy JavaScript & CSS
lint [paths...] Lint JavaScript [& CSS coming soon!]
build [entries...] Bundle JavaScript & CSS
commit Force intelligent commit messages.
deploy [options] [entries...] Bundle & Deploy JavaScript & CSS
lint [paths...] Lint JavaScript [& CSS coming soon!]

Options:

-h, --help output usage information
-V, --version output the version number
-c, --config <path> Path to configuration files.
-e, --env <environment> Environment to use.
-m, --minify Minify built files.
-p, --proxy <address> Proxy calls through to target address.
-s, --serve Serve with budo.
-w, --watch Rebuild on changes with watchify.
Options:

-h, --help output usage information
-V, --version output the version number
-c, --config <path> Path to configuration files.
-e, --env <environment> Environment to use.
-m, --minify Minify built files.
-p, --proxy <address> Proxy calls through to target address.
-s, --serve Serve with budo. Auto-matically rebuilds on changes.
-S, --skip-check-dependencies Skip checking and installing out of date package.json dependencies.
-w, --watch Rebuild on changes with watchify.
```

### `build`
Expand Down
26 changes: 9 additions & 17 deletions bin/mastarm
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ commander
.version(require('../package.json').version)
.usage('<cmd> [options]')
.option('-c, --config <path>', 'Path to configuration files.', path.join(process.cwd(), '/configurations/default'))
.option('-C, --check-dependencies', 'Check and install package.json dependencies.', false)
.option('-e, --env <environment>', 'Environment to use.', process.env.NODE_ENV || 'development')
.option('-m, --minify', 'Minify built files.', false)
.option('-p, --proxy <address>', 'Proxy calls through to target address.')
.option('-s, --serve', 'Serve with budo. Auto-matically rebuilds on changes.', false)
.option('-S, --skip-check-dependencies', 'Skip checking and installing out of date package.json dependencies.', false)
.option('-w, --watch', 'Rebuild on changes with watchify.', false)

commander
.command('build [entries...]')
.description('Bundle JavaScript & CSS')
.action(function (entries) {
dependencyCheck()

const config = loadConfig(process.cwd(), commander.config, commander.env)
const get = (item, backup) => commander[item] || config.settings[item] || backup
const files = parseEntries(entries, get)
Expand Down Expand Up @@ -69,8 +67,6 @@ commander
.option('--cloudfront', 'CloudFront Distribution ID to invalidate.')
.option('--s3bucket', 'S3 Bucket to push to.')
.action(function (entries) {
dependencyCheck()

const pushToS3 = require('../lib/push-to-s3')

const config = loadConfig(process.cwd(), commander.config, commander.env)
Expand All @@ -90,8 +86,6 @@ commander
.command('lint [paths...]')
.description('Lint JavaScript [& CSS coming soon!]')
.action(function () {
dependencyCheck()

const engine = require('standard-engine')
const standard = require('standard')

Expand All @@ -108,6 +102,14 @@ commander

commander.parse(process.argv)

if (!commander.skipCheckDependencies) {
const results = checkDependencies.sync({install: true})
if (results.status !== 0) {
console.error(results.error)
process.exit(results.status)
}
}

function parseEntries (entries, get) {
const files = entries.map((entry) => {
entry = entry.split(':')
Expand All @@ -127,16 +129,6 @@ function parseEntries (entries, get) {
return files
}

function dependencyCheck () {
if (commander.checkDependencies) {
const results = checkDependencies.sync({ install: true })
if (results.status !== 0) {
console.error(results.error)
process.exit(results.status)
}
}
}

/**
* A lot of subcommands utilize exact argument lengths. Pop mastarm to handle it.
*/
Expand Down

0 comments on commit 83a63fe

Please sign in to comment.