Skip to content

Commit ca1f4d9

Browse files
authored
Merge pull request #97 from the-simian/update-dependencies
Update dependencies
2 parents 39c206f + e059257 commit ca1f4d9

File tree

9 files changed

+775
-1655
lines changed

9 files changed

+775
-1655
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
*.sass-cache
66
tmp/
77
reports/
8+
report

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ Usage : es6-plato [options] -d <output_dir> <input files>
145145
es6-plato -r -d report src
146146
```
147147

148+
> Note for Windows Users:
149+
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.
150+
>
151+
152+
148153
![class functions, ya'll](https://cloud.githubusercontent.com/assets/954596/18904476/d1a57302-8523-11e6-85df-b474be8c59a8.PNG)
149154

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

186192
## About
187193

bin/plato

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ var cli = require('../lib/cli');
77
var info = require('../lib/info');
88

99
if (cli.args.v) {
10-
info.version();
11-
process.exit();
10+
info.version();
11+
process.exit();
1212
}
1313

1414
if (cli.args.h) {
15-
info.help();
16-
process.exit();
15+
info.help();
16+
process.exit();
1717
}
1818

19-
cli.exec(function(){
20-
console.log('Done!');
19+
cli.exec(function runPlatoViaCLI(){
20+
console.log('Done!');
2121
});

lib/cli.js

+117-114
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,117 @@
1-
'use strict';
2-
3-
// Node api
4-
var fs = require('fs');
5-
6-
// External libs.
7-
var getopt = require('posix-getopt');
8-
9-
// Local lib
10-
var plato = require('./plato'),
11-
info = require('./info'),
12-
util = require('./util');
13-
14-
15-
function exec(options, done) {
16-
if (typeof options === 'function') {
17-
done = options;
18-
options = undefined;
19-
}
20-
21-
if (options) {
22-
Object.keys(options).forEach(function(key) {
23-
if (!(key in exports.args)) {
24-
exports.args[key] = options[key];
25-
}
26-
});
27-
}
28-
29-
var files = exports.args.files;
30-
var outputDir = exports.args.d.value;
31-
var platoOptions = {
32-
recurse: !!exports.args.r,
33-
q: !!exports.args.q,
34-
title: exports.args.t && exports.args.t.value,
35-
exclude: exports.args.x && new RegExp(exports.args.x.value),
36-
date: exports.args.D && exports.args.D.value,
37-
eslintrc: exports.args.e && exports.args.e.value
38-
};
39-
40-
if (exports.args.l) {
41-
var jshintrc = {};
42-
if (typeof exports.args.l.value === 'string') {
43-
var json = fs.readFileSync(exports.args.l.value).toString();
44-
45-
jshintrc = JSON.parse(util.stripComments(json));
46-
}
47-
platoOptions.jshint = {
48-
globals: jshintrc.globals || {}
49-
};
50-
delete jshintrc.globals;
51-
platoOptions.jshint.options = jshintrc;
52-
}
53-
54-
plato.inspect(files, outputDir, platoOptions, done);
55-
}
56-
57-
58-
59-
60-
function parseArgs(options) { // \/\\*(?:(?!\\*\/)|.|\\n)*?\\*\/
61-
var optionString = '',
62-
required = [],
63-
modal = false;
64-
65-
Object.keys(options).forEach(function(option) {
66-
var def = options[option];
67-
optionString += option;
68-
if (def.type === 'String') {
69-
optionString += ':';
70-
}
71-
if (def.long) {
72-
optionString += '(' + def.long + ')';
73-
}
74-
if (def.required) {
75-
required.push(option);
76-
}
77-
});
78-
79-
var parser = new getopt.BasicParser(optionString, process.argv);
80-
var args = {},
81-
option;
82-
83-
while ((option = parser.getopt())) {
84-
var arg = args[option.option] || {
85-
count: 0
86-
};
87-
arg.count++;
88-
arg.value = option.optarg || true;
89-
90-
args[option.option] = arg;
91-
92-
if (options[option.option].modal) {
93-
modal = true;
94-
}
95-
}
96-
97-
if (!modal) {
98-
required.forEach(function(option) {
99-
if (!args[option] || !args[option].value) {
100-
console.log('Must specify a value for option %s (%s : %s)', option, options[option].long, options[option].desc);
101-
info.help();
102-
process.exit(1);
103-
}
104-
});
105-
}
106-
107-
// what's left in argv
108-
args.files = process.argv.slice(parser.optind());
109-
return args;
110-
}
111-
112-
exports.exec = exec;
113-
exports.options = require('./cli/options');
114-
exports.args = parseArgs(exports.options);
1+
'use strict';
2+
3+
// Node api
4+
var fs = require('fs');
5+
6+
// External libs.
7+
var getopt = require('posix-getopt');
8+
9+
// Local lib
10+
var plato = require('./plato'),
11+
info = require('./info'),
12+
util = require('./util');
13+
14+
15+
function exec(options, done) {
16+
if (typeof options === 'function') {
17+
done = options;
18+
options = undefined;
19+
}
20+
21+
if (options) {
22+
Object.keys(options).forEach(function decorateArgs(key) {
23+
if (!(key in exports.args)) {
24+
exports.args[key] = options[key];
25+
}
26+
});
27+
}
28+
29+
var files = exports.args.files;
30+
var outputDir = exports.args.d.value;
31+
var platoOptions = {
32+
recurse: !!exports.args.r,
33+
q: !!exports.args.q,
34+
title: exports.args.t && exports.args.t.value,
35+
exclude: exports.args.x && new RegExp(exports.args.x.value),
36+
date: exports.args.D && exports.args.D.value,
37+
eslintrc: exports.args.e && exports.args.e.value
38+
};
39+
40+
if (exports.args.l) {
41+
var jshintrc = {};
42+
if (typeof exports.args.l.value === 'string') {
43+
var json = fs.readFileSync(exports.args.l.value).toString();
44+
45+
jshintrc = JSON.parse(util.stripComments(json));
46+
}
47+
platoOptions.jshint = {
48+
globals: jshintrc.globals || {}
49+
};
50+
delete jshintrc.globals;
51+
platoOptions.jshint.options = jshintrc;
52+
}
53+
plato.inspect(files, outputDir, platoOptions, done);
54+
}
55+
56+
57+
58+
59+
function parseArgs(options) { // \/\\*(?:(?!\\*\/)|.|\\n)*?\\*\/
60+
var optionString = '',
61+
required = [],
62+
modal = false;
63+
64+
65+
function parseArg(option) {
66+
var def = options[option];
67+
optionString += option;
68+
if (def.type === 'String') {
69+
optionString += ':';
70+
}
71+
if (def.long) {
72+
optionString += '(' + def.long + ')';
73+
}
74+
if (def.required) {
75+
required.push(option);
76+
}
77+
}
78+
79+
Object.keys(options).forEach(parseArg);
80+
81+
var parser = new getopt.BasicParser(optionString, process.argv);
82+
var args = {},
83+
option;
84+
85+
while ((option = parser.getopt())) {
86+
var arg = args[option.option] || {
87+
count: 0
88+
};
89+
arg.count++;
90+
arg.value = option.optarg || true;
91+
92+
args[option.option] = arg;
93+
94+
if (options[option.option].modal) {
95+
modal = true;
96+
}
97+
}
98+
99+
if (!modal) {
100+
required.forEach(function handleNonModal(option) {
101+
if (!args[option] || !args[option].value) {
102+
// eslint-disable-next-line no-console
103+
console.log('Must specify a value for option %s (%s : %s)', option, options[option].long, options[option].desc);
104+
info.help();
105+
process.exit(1);
106+
}
107+
});
108+
}
109+
// what's left in argv
110+
args.files = process.argv.slice(parser.optind());
111+
112+
return args;
113+
}
114+
115+
exports.exec = exec;
116+
exports.options = require('./cli/options');
117+
exports.args = parseArgs(exports.options);

lib/info.js

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
'use strict';
2-
3-
// Project metadata.
4-
var pkg = require('../package.json'),
5-
options = require('./cli/options.json');
6-
7-
function version() {
8-
console.log(pkg.version);
9-
}
10-
11-
function help() {
12-
console.log('\nUsage : %s [options] file1.js file2.js ... fileN.js', pkg.name);
13-
14-
function displayOptionInCli(shortOption) {
15-
var option = options[shortOption];
16-
console.log(
17-
' -%s%s%s%s',
18-
shortOption,
19-
option.long ? ', --' + option.long : '',
20-
option.type !== 'Boolean' ? ' : ' + option.type : '',
21-
option.required ? ' *required*' : ''
22-
);
23-
24-
console.log(' %s', option.desc);
25-
}
26-
27-
Object.keys(options).forEach(displayOptionInCli);
28-
}
29-
30-
exports.name = pkg.name;
31-
exports.version = version;
32-
exports.help = help;
1+
'use strict';
2+
3+
// Project metadata.
4+
var pkg = require('../package.json'),
5+
options = require('./cli/options.json');
6+
7+
function version() {
8+
console.log(pkg.version);
9+
}
10+
11+
function help() {
12+
console.log('\nUsage : %s [options] file1.js file2.js ... fileN.js', pkg.name);
13+
14+
function displayOptionInCli(shortOption) {
15+
var option = options[shortOption];
16+
console.log(
17+
' -%s%s%s%s',
18+
shortOption,
19+
option.long ? ', --' + option.long : '',
20+
option.type !== 'Boolean' ? ' : ' + option.type : '',
21+
option.required ? ' *required*' : ''
22+
);
23+
24+
console.log(' %s', option.desc);
25+
}
26+
27+
Object.keys(options).forEach(displayOptionInCli);
28+
}
29+
30+
exports.name = pkg.name;
31+
exports.version = version;
32+
exports.help = help;

0 commit comments

Comments
 (0)