Files
atom/script/compile-cson.coffee
Kevin Sawicki & Nathan Sobo 41e1ce4a09 Remove cson2json dependency
The latest release does not work because of CoffeeScript
changes so use a simple compile script to convert CSON
files to JSON files when buildilng.

Closes #348
2013-03-04 18:27:51 -08:00

24 lines
711 B
CoffeeScript

fs = require 'fs'
{exec} = require 'child_process'
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 arguments")
process.exit(1)
contents = fs.readFileSync(inputFile)?.toString() ? ''
exec "node_modules/.bin/coffee -bcp #{inputFile}", (error, stdout, stderr) ->
if error
console.error(error)
process.exit(1)
json = eval(stdout.toString()) ? {}
if json isnt Object(json)
console.error("CSON file does not contain valid JSON")
process.exit(1)
fs.writeFileSync(outputFile, JSON.stringify(json, null, 2))