9
9
// Requirements
10
10
//------------------------------------------------------------------------------
11
11
12
+ const { execSync } = require ( "child_process" )
12
13
const assert = require ( "assert" ) . strict
13
14
const nodeApi = require ( "../lib" )
14
15
const util = require ( "./lib/util" )
@@ -28,81 +29,87 @@ describe("[package-config] it should have an ability to overwrite package's conf
28
29
29
30
beforeEach ( removeResult )
30
31
31
- it ( "Node API should address \"packageConfig\" option" , async ( ) => {
32
- await nodeApi ( "test-task:package-config" , { packageConfig : { "npm-run-all-test" : { test : "OVERWRITTEN" } } } )
33
- assert ( result ( ) === "OVERWRITTEN" )
34
- } )
32
+ const [ major ] = execSync ( "npm --version" , { encoding : "utf8" } ) . trim ( ) . split ( "." )
35
33
36
- it ( "Node API should address \"packageConfig\" option for multiple variables" , async ( ) => {
37
- await nodeApi ( "test-task:package-config2" , { packageConfig : { "npm-run-all-test" : { test : "1" , test2 : "2" , test3 : "3" } } } )
38
- assert ( result ( ) === "1\n2\n3" )
39
- } )
34
+ const supportsOverrides = major <= 6
40
35
41
- describe ( "CLI commands should address \"--a:b=c\" style options" , ( ) => {
42
- it ( "npm-run-all command " , async ( ) => {
43
- await runAll ( [ "test-task:package-config" , "-- npm-run-all-test: test= OVERWRITTEN"] )
44
- assert ( result ( ) === "OVERWRITTEN" )
36
+ if ( supportsOverrides ) {
37
+ it ( "Node API should address \"packageConfig\" option " , async ( ) => {
38
+ await nodeApi ( "test-task:package-config" , { packageConfig : { " npm-run-all-test" : { test : " OVERWRITTEN" } } } )
39
+ assert . equal ( result ( ) , "OVERWRITTEN" )
45
40
} )
46
41
47
- it ( "run-s command " , async ( ) => {
48
- await runSeq ( [ "test-task:package-config " , "-- npm-run-all-test: test=OVERWRITTEN" ] )
49
- assert ( result ( ) === "OVERWRITTEN ")
42
+ it ( "Node API should address \"packageConfig\" option for multiple variables " , async ( ) => {
43
+ await nodeApi ( "test-task:package-config2 " , { packageConfig : { " npm-run-all-test" : { test : "1" , test2 : "2" , test3 : "3" } } } )
44
+ assert . equal ( result ( ) , "1\n2\n3 ")
50
45
} )
51
46
52
- it ( "run-p command" , async ( ) => {
53
- await runPar ( [ "test-task:package-config" , "--npm-run-all-test:test=OVERWRITTEN" ] )
54
- assert ( result ( ) === "OVERWRITTEN" )
47
+ describe ( "CLI commands should address \"--a:b=c\" style options" , ( ) => {
48
+ it ( "npm-run-all command" , async ( ) => {
49
+ await runAll ( [ "test-task:package-config" , "--npm-run-all-test:test=OVERWRITTEN" ] )
50
+ assert . equal ( result ( ) , "OVERWRITTEN" )
51
+ } )
52
+
53
+ it ( "run-s command" , async ( ) => {
54
+ await runSeq ( [ "test-task:package-config" , "--npm-run-all-test:test=OVERWRITTEN" ] )
55
+ assert . equal ( result ( ) , "OVERWRITTEN" )
56
+ } )
57
+
58
+ it ( "run-p command" , async ( ) => {
59
+ await runPar ( [ "test-task:package-config" , "--npm-run-all-test:test=OVERWRITTEN" ] )
60
+ assert . equal ( result ( ) , "OVERWRITTEN" )
61
+ } )
55
62
} )
56
- } )
57
63
58
- describe ( "CLI commands should address \"--a:b=c\" style options for multiple variables" , ( ) => {
59
- it ( "npm-run-all command" , async ( ) => {
60
- await runAll ( [ "test-task:package-config2" , "--npm-run-all-test:test=1" , "--npm-run-all-test:test2=2" , "--npm-run-all-test:test3=3" ] )
61
- assert ( result ( ) === "1\n2\n3" )
64
+ describe ( "CLI commands should address \"--a:b=c\" style options for multiple variables" , ( ) => {
65
+ it ( "npm-run-all command" , async ( ) => {
66
+ await runAll ( [ "test-task:package-config2" , "--npm-run-all-test:test=1" , "--npm-run-all-test:test2=2" , "--npm-run-all-test:test3=3" ] )
67
+ assert . equal ( result ( ) , "1\n2\n3" )
68
+ } )
69
+
70
+ it ( "run-s command" , async ( ) => {
71
+ await runSeq ( [ "test-task:package-config2" , "--npm-run-all-test:test=1" , "--npm-run-all-test:test2=2" , "--npm-run-all-test:test3=3" ] )
72
+ assert . equal ( result ( ) , "1\n2\n3" )
73
+ } )
74
+
75
+ it ( "run-p command" , async ( ) => {
76
+ await runPar ( [ "test-task:package-config2" , "--npm-run-all-test:test=1" , "--npm-run-all-test:test2=2" , "--npm-run-all-test:test3=3" ] )
77
+ assert . equal ( result ( ) , "1\n2\n3" )
78
+ } )
62
79
} )
63
80
64
- it ( "run-s command" , async ( ) => {
65
- await runSeq ( [ "test-task:package-config2" , "--npm-run-all-test:test=1" , "--npm-run-all-test:test2=2" , "--npm-run-all-test:test3=3" ] )
66
- assert ( result ( ) === "1\n2\n3" )
81
+ describe ( "CLI commands should address \"--a:b c\" style options" , ( ) => {
82
+ it ( "npm-run-all command" , async ( ) => {
83
+ await runAll ( [ "test-task:package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
84
+ assert . equal ( result ( ) , "OVERWRITTEN" )
85
+ } )
86
+
87
+ it ( "run-s command" , async ( ) => {
88
+ await runSeq ( [ "test-task:package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
89
+ assert . equal ( result ( ) , "OVERWRITTEN" )
90
+ } )
91
+
92
+ it ( "run-p command" , async ( ) => {
93
+ await runPar ( [ "test-task:package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
94
+ assert . equal ( result ( ) , "OVERWRITTEN" )
95
+ } )
67
96
} )
68
97
69
- it ( "run-p command" , async ( ) => {
70
- await runPar ( [ "test-task:package-config2" , "--npm-run-all-test:test=1" , "--npm-run-all-test:test2=2" , "--npm-run-all-test:test3=3" ] )
71
- assert ( result ( ) === "1\n2\n3" )
98
+ describe ( "CLI commands should transfar overriting nested commands." , ( ) => {
99
+ it ( "npm-run-all command" , async ( ) => {
100
+ await runAll ( [ "test-task:nested-package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
101
+ assert . equal ( result ( ) , "OVERWRITTEN" )
102
+ } )
103
+
104
+ it ( "run-s command" , async ( ) => {
105
+ await runSeq ( [ "test-task:nested-package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
106
+ assert . equal ( result ( ) , "OVERWRITTEN" )
107
+ } )
108
+
109
+ it ( "run-p command" , async ( ) => {
110
+ await runPar ( [ "test-task:nested-package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
111
+ assert . equal ( result ( ) , "OVERWRITTEN" )
112
+ } )
72
113
} )
73
- } )
74
-
75
- describe ( "CLI commands should address \"--a:b c\" style options" , ( ) => {
76
- it ( "npm-run-all command" , async ( ) => {
77
- await runAll ( [ "test-task:package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
78
- assert ( result ( ) === "OVERWRITTEN" )
79
- } )
80
-
81
- it ( "run-s command" , async ( ) => {
82
- await runSeq ( [ "test-task:package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
83
- assert ( result ( ) === "OVERWRITTEN" )
84
- } )
85
-
86
- it ( "run-p command" , async ( ) => {
87
- await runPar ( [ "test-task:package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
88
- assert ( result ( ) === "OVERWRITTEN" )
89
- } )
90
- } )
91
-
92
- describe ( "CLI commands should transfar overriting nested commands." , ( ) => {
93
- it ( "npm-run-all command" , async ( ) => {
94
- await runAll ( [ "test-task:nested-package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
95
- assert ( result ( ) === "OVERWRITTEN" )
96
- } )
97
-
98
- it ( "run-s command" , async ( ) => {
99
- await runSeq ( [ "test-task:nested-package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
100
- assert ( result ( ) === "OVERWRITTEN" )
101
- } )
102
-
103
- it ( "run-p command" , async ( ) => {
104
- await runPar ( [ "test-task:nested-package-config" , "--npm-run-all-test:test" , "OVERWRITTEN" ] )
105
- assert ( result ( ) === "OVERWRITTEN" )
106
- } )
107
- } )
114
+ }
108
115
} )
0 commit comments