@@ -13,13 +13,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
13
13
* @typedef {import("./types").DependencyCheckOptions } DependencyCheckOptions
14
14
*/
15
15
16
- /**
17
- * @param {any } arr1
18
- * @param {any } arr2
19
- */
20
- const isDefaultInput = ( arr1 , arr2 ) =>
21
- JSON . stringify ( arr1 ) === JSON . stringify ( arr2 )
22
-
23
16
const tasks = new Listr (
24
17
[
25
18
{
@@ -30,17 +23,47 @@ const tasks = new Listr(
30
23
*/
31
24
task : async ( ctx , task ) => {
32
25
const forwardOptions = ctx [ '--' ] ? ctx [ '--' ] : [ ]
33
- const input =
34
- ctx . productionOnly &&
35
- isDefaultInput ( ctx . fileConfig . dependencyCheck . input , ctx . input )
36
- ? ctx . fileConfig . dependencyCheck . productionInput
37
- : ctx . input
38
- const noDev = ctx . productionOnly ? [ '--no-dev' ] : [ ]
26
+ const input = ctx . input . length > 0 ? ctx . input : ctx . fileConfig . dependencyCheck . input
27
+ const ignore = ctx . ignore
28
+ . concat ( ctx . fileConfig . dependencyCheck . ignore )
29
+ . reduce ( ( acc , i ) => acc . concat ( '-i' , i ) , /** @type {string[] } */ ( [ ] ) )
30
+
31
+ const args = [ ...input , '--missing' , ...ignore ]
32
+
33
+ if ( pkg . type === 'module' ) {
34
+ // use detective-es6 for js, regular detective for cjs
35
+ args . push (
36
+ '--extensions' , 'cjs:detective-cjs' ,
37
+ '--extensions' , 'js:detective-es6'
38
+ )
39
+ }
40
+
41
+ await execa (
42
+ 'dependency-check' ,
43
+ [ ...args , ...forwardOptions ] ,
44
+ merge (
45
+ {
46
+ localDir : path . join ( __dirname , '..' ) ,
47
+ preferLocal : true
48
+ }
49
+ )
50
+ )
51
+ }
52
+ } ,
53
+ {
54
+ title : 'dependency-check (production only)' ,
55
+ /**
56
+ * @param {GlobalOptions & DependencyCheckOptions } ctx
57
+ * @param {Task } task
58
+ */
59
+ task : async ( ctx , task ) => {
60
+ const forwardOptions = ctx [ '--' ] ? ctx [ '--' ] : [ ]
61
+ const input = ctx . input . length > 0 ? ctx . input : ctx . fileConfig . dependencyCheck . productionInput
39
62
const ignore = ctx . ignore
40
63
. concat ( ctx . fileConfig . dependencyCheck . ignore )
41
64
. reduce ( ( acc , i ) => acc . concat ( '-i' , i ) , /** @type {string[] } */ ( [ ] ) )
42
65
43
- const args = [ ...input , '--missing' , ... noDev , ...ignore ]
66
+ const args = [ ...input , '--missing' , '--no-dev' , ...ignore ]
44
67
45
68
if ( pkg . type === 'module' ) {
46
69
// use detective-es6 for js, regular detective for cjs
0 commit comments