Skip to content

Commit b289149

Browse files
authored
Merge pull request #2 from Havunen/master
Normalize \\ paths to / on windows based systems. Makes all tests pass
2 parents 47bbb21 + d3921e3 commit b289149

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const getPackages = require('get-monorepo-packages');
4-
const { dirname, relative, sep, resolve, isAbsolute } = require('path');
4+
const { dirname, join, relative, sep, normalize, isAbsolute } = require('path');
55

66
const isSubPath = (parent, path) => {
77
const relativePath = relative(parent, path);
@@ -23,7 +23,7 @@ const packages = getPackages(process.cwd()).map(
2323
const resolvePath = (parent, path) => {
2424
if (path[0] !== '.') return path;
2525

26-
return resolve(parent, path);
26+
return join(parent, path).replace(/\\/g, '/');
2727
};
2828

2929
const resolveImport = (context, node, { value, range }, currentPackage) => {
@@ -35,9 +35,11 @@ const resolveImport = (context, node, { value, range }, currentPackage) => {
3535
const pathToImport = path => {
3636
if (path === '') return '.';
3737

38-
if (path[0] !== '.') return `./${path}`;
38+
const normalized = normalize(path).replace(/\\/g, '/');
3939

40-
return path;
40+
if (normalized[0] !== '.') return `./${normalized}`;
41+
42+
return normalized;
4143
};
4244

4345
const findCurrentPackage = context =>

0 commit comments

Comments
 (0)