UNPKG

866 BJavaScriptView Raw
1// @ts-check
2const depcheck = require('depcheck');
3const path = require('path');
4
5const check = new Promise((resolve, reject) => {
6 depcheck(
7 path.join(__dirname, '..'),
8 {
9 ignoreMatches: [
10 '@types/*',
11 'vinyl',
12 'babel-plugin-external-helpers',
13 'polymer-bundler',
14 ],
15 ignoreDirs: [
16 'templates',
17 ],
18 },
19 resolve);
20 })
21 .then((result) => {
22 let invalidFiles = Object.keys(result.invalidFiles) || [];
23 let invalidJsFiles = invalidFiles.filter((f) => f.endsWith('.js'));
24 if (invalidJsFiles.length > 0) {
25 throw new Error(`Invalid files: ${invalidJsFiles}`);
26 }
27 if (result.dependencies.length) {
28 throw new Error(`Unused dependencies: ${result.dependencies}`);
29 }
30 });
31
32check.catch((e) => {
33 console.error(e);
34 process.exit(1);
35});