Comparing version 0.5.0 to 0.6.0
(function() { | ||
var CSON, path, _; | ||
var CSON, optimist, path, _; | ||
@@ -8,6 +8,8 @@ path = require('path'); | ||
optimist = require('optimist'); | ||
CSON = require('./cson'); | ||
module.exports = function(argv) { | ||
var e, inputFile, object, outputFile, outputName; | ||
var e, inputFile, object, options, outputFile, outputName, _ref; | ||
@@ -17,7 +19,11 @@ if (argv == null) { | ||
} | ||
inputFile = argv[0], outputFile = argv[1]; | ||
options = optimist(argv); | ||
options.usage('Usage: csonc <inputFile> [<outputFile>]'); | ||
options.alias('r', 'root').boolean('r').describe('r', 'Require that the input file contain an object at the root.')["default"]('r', false); | ||
argv = options.argv; | ||
_ref = argv._, inputFile = _ref[0], outputFile = _ref[1]; | ||
if ((inputFile != null ? inputFile.length : void 0) > 0) { | ||
inputFile = path.resolve(process.cwd(), inputFile); | ||
} else { | ||
console.error("Input file must be first argument"); | ||
options.showHelp(console.error); | ||
process.exit(1); | ||
@@ -34,5 +40,12 @@ return; | ||
object = CSON.readFileSync(inputFile); | ||
if (argv.r) { | ||
if (!_.isObject(object) || _.isArray(object)) { | ||
console.error("" + inputFile + " does not contain a root object"); | ||
process.exit(1); | ||
return; | ||
} | ||
} | ||
} catch (_error) { | ||
e = _error; | ||
console.error("File does not contain valid CoffeeScript: " + inputFile); | ||
console.error("Parsing " + inputFile + " failed:", e.message); | ||
process.exit(1); | ||
@@ -39,0 +52,0 @@ } |
{ | ||
"name": "season", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "CSON utilities", | ||
@@ -32,3 +32,4 @@ "licenses": [ | ||
"underscore": "~1.4.4", | ||
"coffee-script": "~1.6.2" | ||
"coffee-script": "~1.6.2", | ||
"optimist": "~0.4.0" | ||
}, | ||
@@ -35,0 +36,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12008
251
3
+ Addedoptimist@~0.4.0
+ Addedoptimist@0.4.0(transitive)
+ Addedwordwrap@0.0.3(transitive)