Skip to content

Commit

Permalink
Feature request #13: specify .cson file at command line
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonramirez committed Oct 28, 2012
1 parent 7091453 commit 4384c5e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
45 changes: 29 additions & 16 deletions bin/buildr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

# Requires
cson = require 'cson'
fs = require "fs"
fs = require 'fs'
path = require 'path'
buildr = require __dirname+'/../lib/buildr.coffee'
cwd = process.cwd()
optimist = require 'optimist'

# Argument parsing
argv = optimist.options('file', {
alias: 'f',
default: 'buildr.cson'
}).argv;

filename = path.resolve argv.file

#Preprocessors
preprocessors = [
Expand All @@ -17,18 +26,22 @@ preprocessors = [
new_data
]
data = ''
fs.readFile "#{cwd}/buildr.cson", (err,d) ->
throw err if err
data = d.toString()

console.log "Preprocessing configuration file..."
for p in preprocessors
data = p data
console.log "Preprocessed."

# Parse the config file
cson.parse data, (err,config) ->
throw err if err
myBuildr = buildr.createInstance(config)
myBuildr.process (err) ->
fs.exists filename, (exists) ->
if exists
fs.readFile filename, (err,d) ->
throw err if err
data = d.toString()

console.log "Preprocessing configuration file..."
for p in preprocessors
data = p data
console.log "Preprocessed."

# Parse the config file
cson.parse data, (err,config) ->
throw err if err
myBuildr = buildr.createInstance(config)
myBuildr.process (err) ->
throw err if err
else
console.error "Configuration file not found: #{filename}"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"pulverizr": "0.7.x",
"cson": ">=1.4",
"watch-tree-maintained": "0.1.x",
"caterpillar": "1.x"
"caterpillar": "1.x",
"optimist": ">=0.3"
},
"engines" : {
"node": ">=0.4.0"
Expand Down

0 comments on commit 4384c5e

Please sign in to comment.