1 |
|
2 | const depcheck = require('depcheck');
|
3 | const path = require('path');
|
4 |
|
5 | const check = new Promise((resolve, reject) => {
|
6 | depcheck(
|
7 | path.join(__dirname, '..'),
|
8 | {
|
9 | ignoreDirs: ['test-fixtures'], ignoreMatches: [
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | '@types/*',
|
15 |
|
16 |
|
17 | 'mz',
|
18 | 'multipipe',
|
19 | 'polymer-bundler',
|
20 | 'parse5',
|
21 | 'dom5',
|
22 | '@babel/traverse',
|
23 | 'stream',
|
24 | 'html-minifier',
|
25 | '@polymer/esm-amd-loader',
|
26 | 'babel-plugin-minify-guarded-expressions',
|
27 | ]
|
28 | },
|
29 | resolve);
|
30 | })
|
31 | .then((result) => {
|
32 | const invalidFiles = Object.keys(result.invalidFiles) || [];
|
33 | const invalidJsFiles = invalidFiles.filter((f) => f.endsWith('.js'));
|
34 |
|
35 | const unused = new Set(result.dependencies);
|
36 | if (unused.size > 0) {
|
37 | console.log('Unused dependencies:', unused);
|
38 | throw new Error('Unused dependencies');
|
39 | }
|
40 | });
|
41 |
|
42 | check.catch((e) => {
|
43 | console.error(e);
|
44 | process.exit(1);
|
45 | });
|