Skip to content

Commit e96f2a0

Browse files
committedAug 20, 2020
fix(): fix windows webpack relative paths issue
1 parent 8846c9f commit e96f2a0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
 

‎lib/plugin/utils/plugin-utils.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { head } from 'lodash';
2-
import { dirname, posix } from 'path';
2+
import { posix } from 'path';
33
import * as ts from 'typescript';
44
import {
55
getDecoratorName,
@@ -119,9 +119,10 @@ export function replaceImportPath(typeReference: string, fileName: string) {
119119
if (!importPath) {
120120
return undefined;
121121
}
122+
importPath = convertPath(importPath);
122123
importPath = importPath.slice(2, importPath.length - 1);
123124

124-
let relativePath = posix.relative(dirname(fileName), importPath);
125+
let relativePath = posix.relative(posix.dirname(fileName), importPath);
125126
relativePath = relativePath[0] !== '.' ? './' + relativePath : relativePath;
126127

127128
const nodeModulesText = 'node_modules';
@@ -252,3 +253,14 @@ export function extractTypeArgumentIfArray(type: ts.Type) {
252253
function isOptionalBoolean(text: string) {
253254
return typeof text === 'string' && text === 'boolean | undefined';
254255
}
256+
257+
/**
258+
* Converts Windows specific file paths to posix
259+
* @param windowsPath
260+
*/
261+
function convertPath(windowsPath: string) {
262+
return windowsPath
263+
.replace(/^\\\\\?\\/, '')
264+
.replace(/\\/g, '/')
265+
.replace(/\/\/+/g, '/');
266+
}

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestjs/swagger",
3-
"version": "4.5.12",
3+
"version": "4.5.12-next.1",
44
"description": "Nest - modern, fast, powerful node.js web framework (@swagger)",
55
"author": "Kamil Mysliwiec",
66
"license": "MIT",

0 commit comments

Comments
 (0)
Please sign in to comment.