This repository has been archived by the owner on Aug 5, 2020. It is now read-only.
/
compass_plugin.coffee
59 lines (42 loc) · 1.84 KB
/
compass_plugin.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
ChildProcess = require 'child_process'
Preview = require './preview.coffee'
Build = require './build.coffee'
COMPASS_PROC = if process.platform is 'win32'
"compass.bat"
else
"compass"
class CompassPlugin
bindPreview: (preview_server) ->
console.log "Binding Compass Preview"
ChildProcess.exec "#{COMPASS_PROC} clean", (err, stdout, stderr) ->
if err
console.log "Failed to clean SCSS files. Please manually clean files."
console.log stdout
console.log stderr
child = ChildProcess.spawn "#{COMPASS_PROC}", ['watch']
child.stderr.on 'data', (data) ->
console.log "Compass: #{data}"
# Compass doesn't seem to print to stdout.
child.stdout.on 'data', (data) ->
console.log "Compass: #{data}"
process.on 'exit', () ->
child.kill()
bindBuild: (build) ->
console.log "Binding Compass Build"
build.addHook 'prebuild', (callback) ->
console.log 'Compass Compile'
ChildProcess.exec "#{COMPASS_PROC} clean", (err, stdout, stderr) ->
if err
console.log "Failed to clean SCSS files. Please manually clean files."
console.log stdout
console.log stderr
ChildProcess.exec "#{COMPASS_PROC} compile -e production", (err, stdout, stderr) ->
if err
callback err
return
console.log stdout
console.log stderr
console.log "Compass Compile Complete."
callback()
Preview.registerPlugin CompassPlugin
Build.registerPlugin CompassPlugin