Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Cakefile to build pure JavaScript.

  • Loading branch information...
commit 135b1466c8d2f959c2b4bd71509d917b0794dba9 1 parent 0442473
@brandonramirez brandonramirez authored
Showing with 36 additions and 2 deletions.
  1. +4 −0 .gitignore
  2. +6 −0 .npmignore
  3. +21 −0 Cakefile
  4. +5 −2 package.json
View
4 .gitignore
@@ -0,0 +1,4 @@
+node_modules/
+bin/buildr.js
+lib/buildr.js
+buildr-*.tgz
View
6 .npmignore
@@ -0,0 +1,6 @@
+node_modules/
+bin/buildr.coffee
+lib/buildr.coffee
+.gitignore
+Cakefile
+buildr-*.tgz
View
21 Cakefile
@@ -0,0 +1,21 @@
+fs = require 'fs'
+CoffeeScript = require 'coffee-script'
+
+task 'build', 'compile source files to javascript', (options) ->
+ compile 'lib/buildr.coffee', false
+ compile 'bin/buildr.coffee', true
+
+task 'clean', 'delete compiled output', (options) ->
+ fs.unlink 'lib/buildr.js'
+ fs.unlink 'bin/buildr.js'
+
+compile = (sourceFile, needShebang) ->
+ fs.readFile sourceFile, 'utf8', (error, coffeeCode) ->
+ throw error if error
+
+ javaScript = CoffeeScript.compile(coffeeCode)
+ javaScript = '#!/usr/bin/env node\n' + javaScript if needShebang
+
+ outFile = sourceFile.replace '\.coffee', '.js'
+ fs.writeFile outFile, javaScript, 'utf8', () ->
+ console.log 'built ' + outFile + ' successfully.'
View
7 package.json
@@ -65,11 +65,14 @@
"engines" : {
"node": ">=0.4.0"
},
+ "scripts": {
+ "prepublish": "cake clean build"
+ },
"directories": {
"lib": "lib"
},
"bin": {
- "buildr": "./bin/buildr.coffee"
+ "buildr": "./bin/buildr.js"
},
- "main": "./lib/buildr.coffee"
+ "main": "./lib/buildr.js"
}
Please sign in to comment.
Something went wrong with that request. Please try again.