1 | #!/usr/bin/env node
|
2 |
|
3 | const program = require('commander'),
|
4 | sh = require('shelljs'),
|
5 | rules = require('./lib/audit/rules'),
|
6 | version = require('./package.json').version;
|
7 |
|
8 | program.version(version);
|
9 |
|
10 | const checkPath = ({ find, directory, message }) => {
|
11 | const dirGlob = `{marketplace_builder,modules/**}/${directory}`;
|
12 |
|
13 | const matches = sh
|
14 | .grep('-l', find, dirGlob)
|
15 | .stdout.split('\n')
|
16 | .filter(path => path)
|
17 | .map(path => path.replace('/./', '/'));
|
18 |
|
19 | if (matches.length === 0) {
|
20 | return;
|
21 | }
|
22 | message(matches);
|
23 | console.log('\n');
|
24 | };
|
25 |
|
26 | const Audit = {
|
27 | run: () => rules.map(checkPath),
|
28 | runSingle: filePath => rules.map(options => checkPath({ ...options, directory: filePath }))
|
29 | };
|
30 |
|
31 | Audit.run();
|