Commit e65cfba5 authored by ekaitz's avatar ekaitz
Browse files

[WIP] Make the project compilable:

    Make the project compilable. Still TODO:
    - Make the routes load package.json correctly in build folder:
        Might be solved with other solutions...
    - Make NPM scripts
    - Test everything
parent 6ea809a0
.DS_Store
node_modules
npm-debug.log
\ No newline at end of file
npm-debug.log
build
fs = require 'fs'
path = require 'path'
{spawn, exec} = require 'child_process'
ncp = (require 'ncp').ncp
TARGET = 'build'
build = (source, target) ->
###
# Build sources directory.
###
exec "coffee -c --no-header -o #{target} #{source}",
(err, stdout, stderr) ->
if err then console.err stderr.trim()
else
done source, target
done = (source, target) ->
###
# Show ok message and append to manifest file
###
console.log "#{source}: successfully built in #{target}"
delete_recursive = (target) ->
###
# Delete directory or file recursively
###
if not fs.existsSync target
return
if (fs.lstatSync target).isDirectory()
files = fs.readdirSync target
delete_recursive path.join target, f for f in files
fs.rmdirSync target
console.log "#{target}: Deleted on clean"
else
fs.unlinkSync target
console.log "#{target}: Deleted on clean"
copy_recursive = (source, target) ->
###
# Copy directory recursively
###
target_dir = path.dirname target
if not fs.existsSync target_dir
fs.mkdirSync target_dir
ncp source, target, (err)->
if err then console.error err
else
done source, target
task 'build', 'Build coffeescript to javascript', (opt)->
# Compile code folders
for source in ['lib', 'test', 'routes', 'views']
target = path.join TARGET, source
build source, target
# Compile standalone files
for source in ['server.coffee']
build source, TARGET
# Dump static folders
for source in ['views']
target = path.join TARGET, source
copy_recursive source, target
task 'clean', 'Remove last build', (opt)->
###
# Remove all in Manifest file and the file itself
###
delete_recursive TARGET
......@@ -13,14 +13,15 @@
"test": "node_modules/.bin/mocha test/*.coffee --require coffee-script/register --require should --reporter spec --compilers coffee:coffee-script/register"
},
"dependencies": {
"coffee-script": "1.10.0",
"express": "4.13.3",
"forever": "0.15.1",
"jsdom": "7.0.2",
"marked": "0.3.5",
"ncp": "^2.0.0",
"superagent": "1.4.0"
},
"devDependencies": {
"coffee-script": "1.10.0",
"should": "*",
"mocha": "*",
"publish": "*"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment