-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·60 lines (56 loc) · 1.63 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
#!/usr/bin/env node
'use strict'
var versionChecker = require('./utils/version-checker');
versionChecker(function() {
var fs = require('graceful-fs');
var glob = require('glob');
var split = require('split');
var checkForDeprecations = require('./utils/check-for-deprecations');
var printSummary = require('./utils/print-summary');
var args = process.argv.slice(2);
var filesAndOrFolders = args.length ?
args.length === 1 ? args + '{/**/*,}' : '{' + args.join(',') + '}{/**/*,}' :
'**/*';
glob(filesAndOrFolders, {
nodir: true,
ignore: [
'**/.git/**/*',
'**/node_modules/**/*',
'**/tmp/**/*',
'**/vender/**/*',
'**/logs/**/*',
'**/dist/**/*',
'**/*.+(jpeg|jpg|gif|png|svg|woff|woff2|ttf|otf|eot|log|zip|map|tar|gz|db|sqlite|sqlite3)',
'**/(G|g)ulpfile.js'
]
}, function(err, files) {
if (err) throw err;
var isDeprecationFound = false;
var fileChecks = files.map(function(file) {
return new Promise(function(resolve, reject) {
var lineNum = 0;
fs.createReadStream(file)
.pipe(split())
.on('data', function(line) {
lineNum++;
var lineHasDeprecation = checkForDeprecations({
line: line,
lineNum: lineNum,
file: file
});
if (lineHasDeprecation) {
isDeprecationFound = true;
}
})
.on('end', resolve);
});
});
Promise.all(fileChecks).then(function() {
if (!isDeprecationFound) {
printSummary();
}
}).catch(function(err) {
throw err;
});
});
});