pulsar/script/compile-less.coffee
Kevin Sawicki 7e9c39fd55 Remove less hack
less is no longer vendored and so the previous
window hack is no longer needed.
2013-04-24 11:36:18 -07:00

31 lines
786 B
CoffeeScript

less = require 'less'
fs = require 'fs'
inputFile = process.argv[2]
unless inputFile?.length > 0
console.error("Input file must be first argument")
process.exit(1)
outputFile = process.argv[3]
unless outputFile?.length > 0
console.error("Output file must be second argument")
process.exit(1)
contents = fs.readFileSync(inputFile)?.toString() ? ''
parser = new less.Parser
syncImport: true
paths: [fs.realpathSync("#{__dirname}/../static"), fs.realpathSync("#{__dirname}/../vendor")]
filename: inputFile
logErrorAndExit = (e) ->
console.error("Error compiling less file '#{inputFile}':", e.message)
process.exit(1)
parser.parse contents, (e, tree) ->
logErrorAndExit(e) if e
try
fs.writeFileSync(outputFile, tree.toCSS())
catch e
logErrorAndExit(e)