-
-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c7c0b4
commit 8892c95
Showing
8 changed files
with
1,529 additions
and
1,903 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
lib/creator/transformations/devServer/__snapshots__/devServer.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`devServer transforms correctly using "devServer-0" data 1`] = ` | ||
"module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
devServer: { | ||
contentBase: path.join(__dirname, 'dist'), | ||
compress: true, | ||
port: 9000 | ||
} | ||
} | ||
" | ||
`; | ||
|
||
exports[`devServer transforms correctly using "devServer-1" data 1`] = ` | ||
"module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
devServer: someVar | ||
} | ||
" | ||
`; |
6 changes: 6 additions & 0 deletions
6
lib/creator/transformations/devServer/__testfixtures__/devServer-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
} |
6 changes: 6 additions & 0 deletions
6
lib/creator/transformations/devServer/__testfixtures__/devServer-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
|
||
const utils = require("../../../transformations/utils"); | ||
|
||
/* | ||
* | ||
* Transform for devServer. Finds the devServer property from yeoman and creates a | ||
* property based on what the user has given us. | ||
* | ||
* @param j — jscodeshift API | ||
* @param ast - jscodeshift API | ||
* @param { Object } webpackProperties - Object containing transformation rules | ||
* @returns ast - jscodeshift API | ||
*/ | ||
|
||
module.exports = function(j, ast, webpackProperties) { | ||
function createDevServerProperty(p) { | ||
utils.pushCreateProperty(j, p, "devServer", j.objectExpression([])); | ||
return utils.pushObjectKeys(j, p, webpackProperties, "devServer"); | ||
} | ||
if (webpackProperties && typeof webpackProperties === "object") { | ||
return ast | ||
.find(j.ObjectExpression) | ||
.filter(p => utils.isAssignment(null, p, createDevServerProperty)); | ||
} else if (webpackProperties && webpackProperties.length) { | ||
return ast | ||
.find(j.ObjectExpression) | ||
.filter(p => | ||
utils.isAssignment( | ||
j, | ||
p, | ||
utils.pushCreateProperty, | ||
"devServer", | ||
webpackProperties | ||
) | ||
); | ||
} else { | ||
return ast; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../../transformations/defineTest"); | ||
|
||
defineTest(__dirname, "devServer", "devServer-0",{ | ||
contentBase: "path.join(__dirname, 'dist')", | ||
compress: true, | ||
port: 9000 | ||
}); | ||
defineTest(__dirname, "devServer", "devServer-1", "someVar"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.