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