forked from deedubs/es6-plato
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from the-simian/update-dependencies
Update dependencies
- Loading branch information
Showing
9 changed files
with
775 additions
and
1,655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ node_modules | |
*.sass-cache | ||
tmp/ | ||
reports/ | ||
report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,117 @@ | ||
'use strict'; | ||
|
||
// Node api | ||
var fs = require('fs'); | ||
|
||
// External libs. | ||
var getopt = require('posix-getopt'); | ||
|
||
// Local lib | ||
var plato = require('./plato'), | ||
info = require('./info'), | ||
util = require('./util'); | ||
|
||
|
||
function exec(options, done) { | ||
if (typeof options === 'function') { | ||
done = options; | ||
options = undefined; | ||
} | ||
|
||
if (options) { | ||
Object.keys(options).forEach(function(key) { | ||
if (!(key in exports.args)) { | ||
exports.args[key] = options[key]; | ||
} | ||
}); | ||
} | ||
|
||
var files = exports.args.files; | ||
var outputDir = exports.args.d.value; | ||
var platoOptions = { | ||
recurse: !!exports.args.r, | ||
q: !!exports.args.q, | ||
title: exports.args.t && exports.args.t.value, | ||
exclude: exports.args.x && new RegExp(exports.args.x.value), | ||
date: exports.args.D && exports.args.D.value, | ||
eslintrc: exports.args.e && exports.args.e.value | ||
}; | ||
|
||
if (exports.args.l) { | ||
var jshintrc = {}; | ||
if (typeof exports.args.l.value === 'string') { | ||
var json = fs.readFileSync(exports.args.l.value).toString(); | ||
|
||
jshintrc = JSON.parse(util.stripComments(json)); | ||
} | ||
platoOptions.jshint = { | ||
globals: jshintrc.globals || {} | ||
}; | ||
delete jshintrc.globals; | ||
platoOptions.jshint.options = jshintrc; | ||
} | ||
|
||
plato.inspect(files, outputDir, platoOptions, done); | ||
} | ||
|
||
|
||
|
||
|
||
function parseArgs(options) { // \/\\*(?:(?!\\*\/)|.|\\n)*?\\*\/ | ||
var optionString = '', | ||
required = [], | ||
modal = false; | ||
|
||
Object.keys(options).forEach(function(option) { | ||
var def = options[option]; | ||
optionString += option; | ||
if (def.type === 'String') { | ||
optionString += ':'; | ||
} | ||
if (def.long) { | ||
optionString += '(' + def.long + ')'; | ||
} | ||
if (def.required) { | ||
required.push(option); | ||
} | ||
}); | ||
|
||
var parser = new getopt.BasicParser(optionString, process.argv); | ||
var args = {}, | ||
option; | ||
|
||
while ((option = parser.getopt())) { | ||
var arg = args[option.option] || { | ||
count: 0 | ||
}; | ||
arg.count++; | ||
arg.value = option.optarg || true; | ||
|
||
args[option.option] = arg; | ||
|
||
if (options[option.option].modal) { | ||
modal = true; | ||
} | ||
} | ||
|
||
if (!modal) { | ||
required.forEach(function(option) { | ||
if (!args[option] || !args[option].value) { | ||
console.log('Must specify a value for option %s (%s : %s)', option, options[option].long, options[option].desc); | ||
info.help(); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
|
||
// what's left in argv | ||
args.files = process.argv.slice(parser.optind()); | ||
return args; | ||
} | ||
|
||
exports.exec = exec; | ||
exports.options = require('./cli/options'); | ||
exports.args = parseArgs(exports.options); | ||
'use strict'; | ||
|
||
// Node api | ||
var fs = require('fs'); | ||
|
||
// External libs. | ||
var getopt = require('posix-getopt'); | ||
|
||
// Local lib | ||
var plato = require('./plato'), | ||
info = require('./info'), | ||
util = require('./util'); | ||
|
||
|
||
function exec(options, done) { | ||
if (typeof options === 'function') { | ||
done = options; | ||
options = undefined; | ||
} | ||
|
||
if (options) { | ||
Object.keys(options).forEach(function decorateArgs(key) { | ||
if (!(key in exports.args)) { | ||
exports.args[key] = options[key]; | ||
} | ||
}); | ||
} | ||
|
||
var files = exports.args.files; | ||
var outputDir = exports.args.d.value; | ||
var platoOptions = { | ||
recurse: !!exports.args.r, | ||
q: !!exports.args.q, | ||
title: exports.args.t && exports.args.t.value, | ||
exclude: exports.args.x && new RegExp(exports.args.x.value), | ||
date: exports.args.D && exports.args.D.value, | ||
eslintrc: exports.args.e && exports.args.e.value | ||
}; | ||
|
||
if (exports.args.l) { | ||
var jshintrc = {}; | ||
if (typeof exports.args.l.value === 'string') { | ||
var json = fs.readFileSync(exports.args.l.value).toString(); | ||
|
||
jshintrc = JSON.parse(util.stripComments(json)); | ||
} | ||
platoOptions.jshint = { | ||
globals: jshintrc.globals || {} | ||
}; | ||
delete jshintrc.globals; | ||
platoOptions.jshint.options = jshintrc; | ||
} | ||
plato.inspect(files, outputDir, platoOptions, done); | ||
} | ||
|
||
|
||
|
||
|
||
function parseArgs(options) { // \/\\*(?:(?!\\*\/)|.|\\n)*?\\*\/ | ||
var optionString = '', | ||
required = [], | ||
modal = false; | ||
|
||
|
||
function parseArg(option) { | ||
var def = options[option]; | ||
optionString += option; | ||
if (def.type === 'String') { | ||
optionString += ':'; | ||
} | ||
if (def.long) { | ||
optionString += '(' + def.long + ')'; | ||
} | ||
if (def.required) { | ||
required.push(option); | ||
} | ||
} | ||
|
||
Object.keys(options).forEach(parseArg); | ||
|
||
var parser = new getopt.BasicParser(optionString, process.argv); | ||
var args = {}, | ||
option; | ||
|
||
while ((option = parser.getopt())) { | ||
var arg = args[option.option] || { | ||
count: 0 | ||
}; | ||
arg.count++; | ||
arg.value = option.optarg || true; | ||
|
||
args[option.option] = arg; | ||
|
||
if (options[option.option].modal) { | ||
modal = true; | ||
} | ||
} | ||
|
||
if (!modal) { | ||
required.forEach(function handleNonModal(option) { | ||
if (!args[option] || !args[option].value) { | ||
// eslint-disable-next-line no-console | ||
console.log('Must specify a value for option %s (%s : %s)', option, options[option].long, options[option].desc); | ||
info.help(); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
// what's left in argv | ||
args.files = process.argv.slice(parser.optind()); | ||
|
||
return args; | ||
} | ||
|
||
exports.exec = exec; | ||
exports.options = require('./cli/options'); | ||
exports.args = parseArgs(exports.options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
'use strict'; | ||
|
||
// Project metadata. | ||
var pkg = require('../package.json'), | ||
options = require('./cli/options.json'); | ||
|
||
function version() { | ||
console.log(pkg.version); | ||
} | ||
|
||
function help() { | ||
console.log('\nUsage : %s [options] file1.js file2.js ... fileN.js', pkg.name); | ||
|
||
function displayOptionInCli(shortOption) { | ||
var option = options[shortOption]; | ||
console.log( | ||
' -%s%s%s%s', | ||
shortOption, | ||
option.long ? ', --' + option.long : '', | ||
option.type !== 'Boolean' ? ' : ' + option.type : '', | ||
option.required ? ' *required*' : '' | ||
); | ||
|
||
console.log(' %s', option.desc); | ||
} | ||
|
||
Object.keys(options).forEach(displayOptionInCli); | ||
} | ||
|
||
exports.name = pkg.name; | ||
exports.version = version; | ||
exports.help = help; | ||
'use strict'; | ||
|
||
// Project metadata. | ||
var pkg = require('../package.json'), | ||
options = require('./cli/options.json'); | ||
|
||
function version() { | ||
console.log(pkg.version); | ||
} | ||
|
||
function help() { | ||
console.log('\nUsage : %s [options] file1.js file2.js ... fileN.js', pkg.name); | ||
|
||
function displayOptionInCli(shortOption) { | ||
var option = options[shortOption]; | ||
console.log( | ||
' -%s%s%s%s', | ||
shortOption, | ||
option.long ? ', --' + option.long : '', | ||
option.type !== 'Boolean' ? ' : ' + option.type : '', | ||
option.required ? ' *required*' : '' | ||
); | ||
|
||
console.log(' %s', option.desc); | ||
} | ||
|
||
Object.keys(options).forEach(displayOptionInCli); | ||
} | ||
|
||
exports.name = pkg.name; | ||
exports.version = version; | ||
exports.help = help; |
Oops, something went wrong.