fix: address code review suggestions

This commit is contained in:
Charles Kerr
2018-09-04 01:09:47 -05:00
parent 81d8214b09
commit dd7af018cb

View File

@@ -11,9 +11,7 @@ const SOURCE_ROOT = path.normalize(path.dirname(__dirname))
const LINTER_PATH = path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py')
const ROOTS = ['atom', 'brightray'].map(token => path.join(SOURCE_ROOT, token))
function isBootstrapped () {
return fs.existsSync(LINTER_PATH)
}
const isBootstrapped = () => fs.existsSync(LINTER_PATH)
function callCpplint (filenames, args) {
if (args.verbose) console.log([LINTER_PATH, ...filenames].join(' '))
@@ -57,9 +55,7 @@ async function findFiles (top, test) {
})
}
function isCCFile (filename) {
return filename.endsWith('.cc') || filename.endsWith('.h')
}
const isCCFile = filename => filename.endsWith('.cc') || filename.endsWith('.h')
const blacklist = new Set([
['atom', 'browser', 'mac', 'atom_application.h'],
@@ -100,15 +96,15 @@ async function main () {
const args = parseCommandLine()
let filenames = []
for (let root of ROOTS) {
let files = await findFiles(root, isCCFile)
for (const root of ROOTS) {
const files = await findFiles(root, isCCFile)
filenames.push(...files)
}
filenames = filenames.filter(x => !blacklist.has(x))
if (args.onlyChanged) {
let whitelist = await findChangedFiles(SOURCE_ROOT)
const whitelist = await findChangedFiles(SOURCE_ROOT)
filenames = filenames.filter(x => whitelist.has(x))
}