forked from mutewinter/tapas-with-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
92 lines (69 loc) · 2.02 KB
/
Gruntfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
path = require 'path'
{ spawn } = require 'child_process'
module.exports = (grunt) ->
###
# Took this from grunt-brunch, since the package doesn't work
###
grunt.registerMultiTask "brunch", "Brunch asset pipeline", ->
# Get the options
options = grunt.config('brunch')[@target]
grunt.verbose.writeflags options, "Options"
{ action, port, async, production } = options
action ?= 'serve'
port ?= 8888
async ?= false
production ?= false
# Always run asynchronously unless otherwise specified
done = @async() unless async
# Available command list
brunchPath = path.resolve "#{__dirname}/node_modules/.bin/brunch"
command = switch action
when 'serve'
"#{brunchPath} watch --server --port #{port}"
when 'watch'
"#{brunchPath} watch --port #{port}"
when 'compile'
"#{brunchPath} build"
when 'build'
"#{brunchPath} build -P"
process.env.BRUNCH_ENV = 'production' if production
# Run it
[ cmd, args... ] = command.split ' '
brunch = spawn cmd, args
# Capture all output
brunch.stdout.pipe process.stdout
brunch.stderr.pipe process.stdout
# Finish on close
brunch.on 'close', done unless async
# Quit child process on exit
process.on 'exit', ->
brunch.kill 'SIGHUP'
###
# Grunt config
###
grunt.initConfig
pkg: grunt.file.readJSON "package.json"
brunch:
serve:
action: 'serve'
port: 8888
async: false
watch:
action: 'watch'
build:
action: 'build'
production: true
rsync:
options:
args: ["--verbose"]
recursive: true
production:
options:
src: "public"
dest: ""
host: "[email protected]"
grunt.loadNpmTasks 'grunt-rsync'
grunt.registerTask "serve", [ "brunch:serve" ]
grunt.registerTask "build", [ "brunch:build" ]
grunt.registerTask "deploy", [ "build", "rsync:production"]
grunt.registerTask "default", [ "serve"]