@@ -30,62 +30,36 @@ function createConfig() {
30
30
*
31
31
* @returns {boolean }
32
32
*/
33
- function isWindows ( ) {
34
- return process . platform === 'win32' ;
35
- }
33
+ const isWindows = ( process . platform === 'win32' ) ;
36
34
37
35
describe ( 'path-util getContentBase()' , ( ) => {
38
36
describe ( 'getContentBase()' , ( ) => {
39
37
it ( 'contentBase is calculated correctly' , function ( ) {
40
- if ( isWindows ( ) ) {
41
- this . skip ( ) ;
42
- }
43
-
44
38
const config = createConfig ( ) ;
45
39
config . runtimeConfig . useDevServer = true ;
46
40
config . runtimeConfig . devServerUrl = 'http://localhost:8080/' ;
47
- config . outputPath = '/tmp/public/build' ;
41
+ config . outputPath = isWindows ? 'C:\\tmp\\public\\build' : '/tmp/public/build' ;
48
42
config . setPublicPath ( '/build/' ) ;
49
43
config . addEntry ( 'main' , './main' ) ;
50
44
51
45
const actualContentBase = pathUtil . getContentBase ( config ) ;
52
46
// contentBase should point to the "document root", which
53
47
// is calculated as outputPath, but without the publicPath portion
54
- expect ( actualContentBase ) . to . equal ( '/tmp/public' ) ;
48
+ expect ( actualContentBase ) . to . equal ( isWindows ? 'C:\\tmp\\public' : '/tmp/public' ) ;
55
49
} ) ;
56
50
57
51
it ( 'contentBase works ok with manifestKeyPrefix' , function ( ) {
58
- if ( isWindows ( ) ) {
59
- this . skip ( ) ;
60
- }
61
-
62
52
const config = createConfig ( ) ;
63
53
config . runtimeConfig . useDevServer = true ;
64
54
config . runtimeConfig . devServerUrl = 'http://localhost:8080/' ;
65
- config . outputPath = '/tmp/public/build' ;
55
+ config . outputPath = isWindows ? 'C:\\tmp\\public\\build' : '/tmp/public/build' ;
66
56
config . setPublicPath ( '/subdirectory/build' ) ;
67
57
// this "fixes" the incompatibility between outputPath and publicPath
68
58
config . setManifestKeyPrefix ( '/build/' ) ;
69
59
config . addEntry ( 'main' , './main' ) ;
70
60
71
61
const actualContentBase = pathUtil . getContentBase ( config ) ;
72
- expect ( actualContentBase ) . to . equal ( '/tmp/public' ) ;
73
- } ) ;
74
-
75
- it ( 'contentBase is calculated correctly on Windows' , function ( ) {
76
- if ( ! isWindows ( ) ) {
77
- this . skip ( ) ;
78
- }
79
-
80
- const config = createConfig ( ) ;
81
- config . runtimeConfig . useDevServer = true ;
82
- config . runtimeConfig . devServerUrl = 'http://localhost:8080/' ;
83
- config . outputPath = 'C:\\projects\\webpack-encore\\public\\build' ;
84
- config . setPublicPath ( '/build/' ) ;
85
- config . addEntry ( 'main' , './main' ) ;
86
-
87
- const actualContentBase = pathUtil . getContentBase ( config ) ;
88
- expect ( actualContentBase ) . to . equal ( 'C:\\projects\\webpack-encore\\public' ) ;
62
+ expect ( actualContentBase ) . to . equal ( isWindows ? 'C:\\tmp\\public' : '/tmp/public' ) ;
89
63
} ) ;
90
64
} ) ;
91
65
@@ -114,7 +88,8 @@ describe('path-util getContentBase()', () => {
114
88
115
89
it ( 'when outputPath and publicPath are incompatible, manifestKeyPrefix must be set' , ( ) => {
116
90
const config = createConfig ( ) ;
117
- config . outputPath = '/tmp/public/build' ;
91
+
92
+ config . outputPath = isWindows ? 'C:\\tmp\\public\\build' : '/tmp/public/build' ;
118
93
config . addEntry ( 'main' , './main' ) ;
119
94
// pretend we're installed to a subdirectory
120
95
config . setPublicPath ( '/subdirectory/build' ) ;
@@ -126,30 +101,18 @@ describe('path-util getContentBase()', () => {
126
101
} ) ;
127
102
128
103
describe ( 'getRelativeOutputPath' , ( ) => {
129
- it ( 'Works with Unix paths' , function ( ) {
130
- if ( isWindows ( ) ) {
131
- this . skip ( ) ;
132
- }
133
-
104
+ it ( 'basic usage' , function ( ) {
134
105
const config = createConfig ( ) ;
135
- config . runtimeConfig . context = '/tmp/webpack-encore' ;
136
- config . outputPath = '/tmp/webpack-encore/public/build' ;
137
-
138
- const actualPath = pathUtil . getRelativeOutputPath ( config ) ;
139
- expect ( actualPath ) . to . equal ( 'public/build' ) ;
140
- } ) ;
141
-
142
- it ( 'Works with Windows paths' , function ( ) {
143
- if ( ! isWindows ( ) ) {
144
- this . skip ( ) ;
106
+ if ( isWindows ) {
107
+ config . runtimeConfig . context = 'C:\\projects\\webpack-encore' ;
108
+ config . outputPath = 'C:\\projects\\webpack-encore\\public\\build' ;
109
+ } else {
110
+ config . runtimeConfig . context = '/tmp/webpack-encore' ;
111
+ config . outputPath = '/tmp/webpack-encore/public/build' ;
145
112
}
146
113
147
- const config = createConfig ( ) ;
148
- config . runtimeConfig . context = 'C:\\projects\\webpack-encore' ;
149
- config . outputPath = 'C:\\projects\\webpack-encore\\public\\build' ;
150
-
151
114
const actualPath = pathUtil . getRelativeOutputPath ( config ) ;
152
- expect ( actualPath ) . to . equal ( 'public\\build' ) ;
115
+ expect ( actualPath ) . to . equal ( isWindows ? 'public\\build' : 'public/ build') ;
153
116
} ) ;
154
117
} ) ;
155
118
} ) ;
0 commit comments