Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #15 from altitudebreath/master

Macro preprocessor
  • Loading branch information...
commit 6a9aa1e9ed28a570166e669e4dc06af0b693763c 2 parents 0442473 + 284a426
@brandonramirez brandonramirez authored
Showing with 27 additions and 6 deletions.
  1. +27 −6 bin/buildr.coffee
View
33 bin/buildr.coffee
@@ -2,12 +2,33 @@
# Requires
cson = require 'cson'
+fs = require "fs"
buildr = require __dirname+'/../lib/buildr.coffee'
cwd = process.cwd()
-# Parse the config file
-cson.parseFile "#{cwd}/buildr.cson", (err,config) ->
- throw err if err
- myBuildr = buildr.createInstance(config)
- myBuildr.process (err) ->
- throw err if err
+#Preprocessors
+preprocessors = [
+ (data) ->
+ new_data = data
+ p = /##def\s+(\w+)\s*"(.*?)"/g
+ while m = p.exec data
+ console.log "--> " + m[0]
+ new_data = new_data.replace RegExp(m[1], 'g'), m[2]
+ 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) ->
+ throw err if err
Please sign in to comment.
Something went wrong with that request. Please try again.