Skip to content

Commit

Permalink
Merge pull request #97 from the-simian/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
the-simian authored Aug 24, 2019
2 parents 39c206f + e059257 commit ca1f4d9
Show file tree
Hide file tree
Showing 9 changed files with 775 additions and 1,655 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
*.sass-cache
tmp/
reports/
report
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ Usage : es6-plato [options] -d <output_dir> <input files>
es6-plato -r -d report src
```

> Note for Windows Users:
If you are on Windows, you might want to put your glob in quotes if you use a tool such as cygwin, conemu or some other emulator, and you are also targeting files in directories, otherwise the emulator might incorrectly expand the glob before it is handled internally by es6-plato. For instance, if you want to use `/src/**/*.js` and the results are ignoring the root try `'./src/**/*.js'` instead.
>

![class functions, ya'll](https://cloud.githubusercontent.com/assets/954596/18904476/d1a57302-8523-11e6-85df-b474be8c59a8.PNG)

## Data sources
Expand Down Expand Up @@ -181,7 +186,8 @@ es6-plato -r -d report src
| 1.1.16 | Update eslint to 5.14.0 |
| 1.2.0 | Update eslint, globby, lodash, typhon-complex and others |
| 1.2.1 | reverts typhon-complex for now, see issue #95 |
| 1.2.1 | reverts globby, 10 doesn't by default handle windows slashes |
| 1.2.2 | reverts globby, 10 doesn't by default handle windows slashes |
| 1.2.3 | updates eslint and globby |

## About

Expand Down
12 changes: 6 additions & 6 deletions bin/plato
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ var cli = require('../lib/cli');
var info = require('../lib/info');

if (cli.args.v) {
info.version();
process.exit();
info.version();
process.exit();
}

if (cli.args.h) {
info.help();
process.exit();
info.help();
process.exit();
}

cli.exec(function(){
console.log('Done!');
cli.exec(function runPlatoViaCLI(){
console.log('Done!');
});
231 changes: 117 additions & 114 deletions lib/cli.js
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);
64 changes: 32 additions & 32 deletions lib/info.js
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;
Loading

0 comments on commit ca1f4d9

Please sign in to comment.