-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
79 lines (67 loc) · 1.88 KB
/
index.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
'use strict';
var path = require('path');
var del = require('delete');
var isValid = require('is-valid-app');
var dir = path.resolve.bind(path, __dirname, 'templates');
module.exports = function(app) {
if (!isValid(app, 'update-eslint')) return;
/**
* Register a generator
*/
app.register('generate-eslint', require('generate-eslint'));
/**
* Update the `.eslintrc.json` file in the current working directory.
*
* ```sh
* $ update eslint
* ```
* @name eslint
* @api public
*/
app.task('eslint', {silent: true}, ['eslint-del', 'eslint-new']);
/**
* Adds a new `.eslintrc.json` file by running [generate-eslint][]. The template
* is [customizable](#customization). This task is also aliased as `eslint-new`
* to provide a semantic task name for calling this task programmatically.
*
* ```sh
* $ update eslint:new
* ```
* @name eslint:new
* @api public
*/
app.task('new', ['eslint-new']);
app.task('eslint-new', {silent: true}, function(cb) {
app.generate('generate-eslint', cb);
});
/**
* Delete the `eslintrc` and `jshint` files in the current working directory. Also
* aliased as `eslint-del` to provide a semantic task name for calling this task
* programmatically.
*
* ```sh
* $ update eslint:del
* ```
* @name eslint:del
* @api public
*/
app.task('del', ['eslint-del']);
app.task('eslint-del', {silent: true}, function() {
return del(['.jshintrc', '.eslintrc.json', '.eslintrc'], {cwd: app.cwd})
.then(function(files) {
if (files.length && app.options.verbose) {
console.log('deleted', files.join(', '));
}
});
});
/**
* Alias to allow running the [eslint](#eslinteslint) task with the following command:
*
* ```sh
* $ update eslint
* ```
* @name eslint
* @api public
*/
app.task('default', {silent: true}, ['eslint']);
};