-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathindex.js
executable file
·63 lines (58 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
61
62
#!/usr/bin/env node
'use strict'
require('./helpers/check-if-outdated')(function () {
var fs = require('graceful-fs')
var glob = require('glob')
var split = require('split')
var checkForDeprecations = require('./helpers/check-for-deprecations')
var printSummary = require('./helpers/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/**/*',
'**/vendor/**/*',
'**/cache/**/*',
'**/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 (error, files) {
if (error) throw error
var deprecationsFound = 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) {
deprecationsFound = true
}
})
.on('end', resolve)
})
})
Promise.all(fileChecks)
.then(function () {
printSummary(deprecationsFound)
})
.catch(function (error) {
throw error
})
})
})