Skip to content

Commit bbf407e

Browse files
committed
fixed: path.resolve for windows
1 parent 6444f8a commit bbf407e

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

build.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "tools for miniprogram custom component unit test",
55
"main": "index.js",
66
"scripts": {
7+
"dev": "webpack --watch",
78
"build": "webpack",
89
"karma": "npm run build && karma start",
910
"test": "jest --bail",

src/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ function setBrowserEnv() {
3636
fs = {
3737
readFileSync(filePath) {
3838
const fileMap = window.__FILE_MAP__ || {}
39-
return fileMap[filePath] || null
39+
if (fileMap[filePath]) {
40+
return fileMap[filePath]
41+
} else if (filePath[0] === '/') {
42+
// path.resolve 可能会加上 /,在 windows 下会有问题
43+
return fileMap[filePath.substr(1)] || null
44+
}
45+
46+
return null
4047
}
4148
}
4249
window.require = runJs = filePath => {

0 commit comments

Comments
 (0)