werkzeug
Version:
compiles ts, coffee, sass/scss, less/ stylus and packs browser ready bundles
74 lines (53 loc) • 1.64 kB
text/coffeescript
FSE = require 'fs-extra'
FSU = require '../utils/fsu'
PH = require '../utils/path-helper'
IPC = require '../utils/ipc'
Log = require '../utils/log'
class AssetCompiler
constructor: () ->
= null
= null
= 0
= new IPC(process, @)
init: () ->
null
compile: (files) ->
= []
= 0
if not .out
return
for file in files
++
path = file.path
if not file.removed
path
else
path
if == 0
null
copy: (path) ->
out = PH.outFromIn , 'assets', path
FSE.copy path, out, (error) =>
.push {path:path, error:error} if error
if -- == 0
null
null
remove: (path, out) ->
out = PH.outFromIn , null, path, true
map = out + '.map'
FSE.remove out, (error) =>
if FSU.isFile map
++
FSE.remove map, (error) =>
.push {path:map, error:error} if error
if -- == 0
null
.push {path:out, error:error} if error
if -- == 0
null
null
compiled: () ->
#console.log 'assets.compiled!!!'
.send 'compiled', 'assets',
module.exports = new AssetCompiler()