forked from brave/brave-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudit.js
More file actions
34 lines (30 loc) · 1.1 KB
/
audit.js
File metadata and controls
34 lines (30 loc) · 1.1 KB
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const path = require('path')
const fs = require('fs')
const util = require('../lib/util')
const baseDir = path.resolve(path.join(__dirname, '..'))
const braveDir = path.join(baseDir, 'src', 'brave')
const braveVendorDir = path.join(braveDir, 'vendor')
const syncDir = path.join(braveDir, 'components', 'brave_sync', 'extension')
/**
* Runs npm audit on a given directory located at pathname
*/
function npmAudit (pathname) {
if (fs.existsSync(path.join(pathname, 'package.json')) &&
fs.existsSync(path.join(pathname, 'package-lock.json'))) {
console.log('Auditing', pathname)
util.run('npm', ['audit'], { cwd: pathname })
} else {
console.log('Skipping audit of', pathname)
}
}
npmAudit(baseDir)
npmAudit(braveDir)
fs.readdirSync(braveVendorDir).forEach((dir) => {
npmAudit(path.join(braveVendorDir, dir))
})
fs.readdirSync(syncDir).forEach((dir) => {
npmAudit(path.join(syncDir, dir))
})