Comparing version 0.0.4 to 0.0.5
29
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
var cbml = require('./'); | ||
var optimist = require('optimist'); | ||
var mkdirp = require('mkdirp'); | ||
var fs = require('fs'); | ||
@@ -9,21 +11,9 @@ var path = require('path'); | ||
/* | ||
* 保证目录存在 | ||
* | ||
* @param{String} dir 目录 | ||
*/ | ||
function forceDirSync(dir) { | ||
if (!fs.existsSync(dir)) { | ||
forceDirSync(path.dirname(dir)); | ||
fs.mkdirSync(dir); | ||
} | ||
} | ||
var argv = optimist | ||
.usage('$0 input1.js [input2.js] -o output') | ||
.alias("o", "output") | ||
.alias('o', 'output') | ||
.describe('o', 'output file.') | ||
.string('o') | ||
.alias("v", "version") | ||
.describe("v", "Print version number and exit.") | ||
.alias('v', 'version') | ||
.describe('v', 'Print version number and exit.') | ||
.wrap(80) | ||
@@ -33,3 +23,3 @@ .argv; | ||
if (argv.version) { | ||
var json = require("../package.json"); | ||
var json = require('../package.json'); | ||
console.log(json.name + ' ' + json.version); | ||
@@ -46,3 +36,3 @@ return; | ||
var filenames = []; | ||
argv._.forEach(function(filename) { | ||
argv._.forEach(function (filename) { | ||
filenames.push(filename); | ||
@@ -53,7 +43,8 @@ contents.push(JSON.stringify(cbml.parse(fs.readFileSync(filename), argv), null, ' ')); | ||
if (argv.output) { | ||
forceDirSync(path.dirname(argv.output)); | ||
mkdirp(path.dirname(argv.output)); | ||
fs.writeFileSync(argv.output, content); | ||
console.log(util.format('%j cbml output complete.', filenames)); | ||
} else { | ||
} | ||
else { | ||
console.log(content); | ||
} |
{ | ||
"name": "cbml", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "CBML Parser", | ||
@@ -21,4 +21,5 @@ "homepage": "https://github.com/cbml/cbmljs", | ||
"dependencies": { | ||
"colors": "1.0.3", | ||
"optimist": "0.6.1" | ||
"mkdirp": "^0.5.0", | ||
"colors": "^1.0.3", | ||
"optimist": "^0.6.1" | ||
}, | ||
@@ -25,0 +26,0 @@ "devDependencies": { |
@@ -351,2 +351,3 @@ (function (exportName) { | ||
case 'commentRight': | ||
case 'right': | ||
if (token.type === 'right') { | ||
@@ -353,0 +354,0 @@ items = lefts; |
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
13171
3
440
+ Addedmkdirp@^0.5.0
+ Addedcolors@1.4.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
- Removedcolors@1.0.3(transitive)
Updatedcolors@^1.0.3
Updatedoptimist@^0.6.1