Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1543595

Browse filesBrowse files
Correct Windows path handling in new aspnet-webpack feature
1 parent 3d77a21 commit 1543595
Copy full SHA for 1543595

File tree

Expand file treeCollapse file tree

2 files changed

+13
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-2
lines changed
Open diff view settings
Collapse file

‎src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json‎

Copy file name to clipboardExpand all lines: src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aspnet-webpack",
3-
"version": "1.0.19",
3+
"version": "1.0.20",
44
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
55
"main": "index.js",
66
"scripts": {
Collapse file

‎src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts‎

Copy file name to clipboardExpand all lines: src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
124124

125125
function copyRecursiveSync(from: typeof fs, to: typeof fs, rootDir: string, exclude: RegExp[]) {
126126
from.readdirSync(rootDir).forEach(filename => {
127-
const fullPath = path.join(rootDir, filename);
127+
const fullPath = pathJoinSafe(rootDir, filename);
128128
const shouldExclude = exclude.filter(re => re.test(fullPath)).length > 0;
129129
if (!shouldExclude) {
130130
const fileStat = from.statSync(fullPath);
@@ -138,6 +138,17 @@ function copyRecursiveSync(from: typeof fs, to: typeof fs, rootDir: string, excl
138138
});
139139
}
140140

141+
function pathJoinSafe(rootPath: string, filePath: string) {
142+
// On Windows, MemoryFileSystem's readdirSync output produces directory entries like 'C:'
143+
// which then trigger errors if you call statSync for them. Avoid this by detecting drive
144+
// names at the root, and adding a backslash (so 'C:' becomes 'C:\', which works).
145+
if (rootPath === '/' && path.sep === '\\' && filePath.match(/^[a-z0-9]+\:$/i)) {
146+
return filePath + '\\';
147+
} else {
148+
return path.join(rootPath, filePath);
149+
}
150+
}
151+
141152
function beginWebpackWatcher(webpackConfig: webpack.Configuration) {
142153
const compiler = webpack(webpackConfig);
143154
compiler.watch({ /* watchOptions */ }, (err, stats) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.