-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a build system via Cake (but see also issue #1)
- Loading branch information
1 parent
a29bc92
commit 01439de
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
fs = require 'fs' | ||
path = require 'path' | ||
{exec} = require 'child_process' | ||
|
||
libFiles = [ | ||
# omit src/ and .js to make the below lines a little shorter | ||
'header' | ||
'core' | ||
] | ||
|
||
task 'build', "Concatenate source files into a single library file", -> | ||
exec "mkdir -p 'build'", (err, stdout, stderr) -> | ||
# Concatenate files | ||
libContents = new Array remaining = libFiles.length | ||
for file, index in libFiles then do (file, index) -> | ||
fs.readFile "src/#{file}.js", 'utf8', (err, fileContents) -> | ||
throw err if err | ||
libContents[index] = fileContents | ||
process() if --remaining is 0 | ||
# Translate concatenated file | ||
process = -> | ||
fs.writeFile 'dist/glquery.js', libContents.join('\n\n'), 'utf8', (err) -> | ||
throw err if err | ||
console.log "Done." | ||
|
||
task 'fetch:npm', "Fetch the npm package manager", -> | ||
exec "curl http://npmjs.org/install.sh | sudo sh", (err, stdout, stderr) -> | ||
throw err if err | ||
console.log stdout + stderr | ||
console.log "Done." | ||
|
||
task 'fetch:uglifyjs', "Fetch the UglifyJS minification tool", -> | ||
exec "npm install uglify-js", (err, stdout, stderr) -> | ||
throw err if err | ||
console.log stdout + stderr | ||
console.log "Done." | ||
|
||
task 'minify', "Minify the resulting application file after build", -> | ||
path.exists 'node_modules/.bin/uglifyjs', (exists) -> | ||
if exists | ||
exec "node_modules/.bin/uglifyjs dist/glquery.js > dist/glquery.min.js", (err, stdout, stderr) -> | ||
throw err if err | ||
console.log stdout + stderr | ||
console.log "Done." | ||
else | ||
exec "uglifyjs dist/glquery.js > dist/glquery.min.js", (err, stdout, stderr) -> | ||
throw err if err | ||
console.log stdout + stderr | ||
console.log "Done." | ||
|
||
task 'clean', "Cleanup all build files and distribution files", -> | ||
exec "rm -rf build;rm dist/glquery.js;rm dist/glquery.min.js", (err, stdout, stderr) -> | ||
console.log stdout + stderr | ||
console.log "Done." | ||
|