-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcli.js
executable file
·88 lines (76 loc) · 1.61 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env node
/**
* JSXHint CLI tool
*
* Copyright 2013 (c) Condé Nast
*
* Please see LICENSE for details
*
*/
'use strict';
var jsxhint = require('./jsxhint');
var pkgInfo = require('./package');
var runnel = require('runnel');
var ArgParse = require('argparse').ArgumentParser;
var globs = [];
var args = {};
var parser = new ArgParse({
version: pkgInfo.version,
addHelp: true,
description: pkgInfo.description,
debug: true
});
parser.addArgument(
['-f', '--ignore-file'],
{
help: 'Use ignore file. Default: .gitignore',
defaultValue: '.gitignore',
dest: 'ignoreFile'
}
);
parser.addArgument(
['-i', '--ignore'],
{
help: "Ignore pattern. Globs MUST be wrapped in quotes!",
defaultValue: '',
nargs: '+',
dest: 'ignoreList'
}
);
parser.addArgument(
['-r', '--jshintrc'],
{
help: 'Use jshintrc. Default: .jshintrc',
defaultValue: '.jshintrc',
dest: 'jshintrc'
}
);
parser.addArgument(
['-g', '--glob'],
{
help: 'Specify file pattern to hint. Globs MUST be wrapped in quotes!',
defaultValue: [],
action: 'append',
type: 'string',
dest: 'globs'
}
);
// this oddly wraps the arguments in an extra array...
parser.addArgument(
['files'],
{
help: 'List of files to hint',
nargs: '+',
action: 'append'
}
);
try {
args = parser.parseArgs();
} catch (e){
console.log(e.message.replace(/cli\.js/, 'jsxhint'));
process.exit(1);
}
globs = args.globs.concat(args.files[0]);
var prjRoot = process.cwd();
var tasks = jsxhint.generateTasks(globs, args.ignoreList, args.ignoreFile, args.jshintrc, prjRoot);
runnel(tasks);