Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 8676189

Browse files
committed
fix: Windows separator issue
Replacing all Windows' "\" separator to "/" to avoid throwing errors on successful tests
1 parent 21b9537 commit 8676189

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { join, resolve, relative, isAbsolute, dirname, basename } from 'path';
2+
import { join, resolve, relative, isAbsolute, dirname, basename, sep } from 'path';
33
import fs from 'fs';
44
import { StringLiteral } from 'babel-types';
55
import template from 'lodash.template';
@@ -161,7 +161,7 @@ export default function({ types: t }) {
161161
if(!isAbsolute(aliasTo)) {
162162
aliasTo = join(process.cwd(), aliasTo);
163163
}
164-
let relativeFilePath = relative(dirname(filename), aliasTo).replace(/\\/g, '/');
164+
let relativeFilePath = relative(dirname(filename), aliasTo).split(sep).join('/');
165165

166166
// In case the file path is the root of the alias, need to put a dot to avoid having an absolute path
167167
if(relativeFilePath.length === 0) {

test/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ test('works with libraries targeted with path.resolve', t => {
9696
test('should throw an error when there is no resolve config', t => {
9797
t.throws(
9898
() => transformFixture('basic/absolute.js', {config: 'no-resolve.config.js'}),
99-
`${path.resolve(__dirname, 'fixtures/basic/absolute.js')}: The resolved config file doesn\'t contain a resolve configuration`
99+
`${path.resolve(__dirname, 'fixtures/basic/absolute.js').split(path.sep).join('/')}: The resolved config file doesn\'t contain a resolve configuration`
100100
);
101101
});
102102

test/no-default-config/no-config.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import {transformFixture} from '../utils';
55
test('should throw an error when no config is found', t => {
66
t.throws(
77
() => transformFixture('basic/absolute.js', {config: 'my-webpack.config.js'}),
8-
`${path.resolve(__dirname, '../fixtures/basic/absolute.js')}: Cannot find any of these configuration files: my-webpack.config.js, webpack.config.js, webpack.config.babel.js`
8+
`${path.resolve(__dirname, '../fixtures/basic/absolute.js').split(path.sep).join('/')}: Cannot find any of these configuration files: my-webpack.config.js, webpack.config.js, webpack.config.babel.js`
99
);
1010
});

0 commit comments

Comments
 (0)