Skip to content

Commit 0049955

Browse files
author
Vladimir Kalmykov
authored
Merge pull request #2 from morulus/bugfix/1
Replace Windows-style path separators to Unix-style (#1)
2 parents 2b85971 + 2d002f8 commit 0049955

File tree

11 files changed

+3099
-3510
lines changed

11 files changed

+3099
-3510
lines changed

__tests__/winOs.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
const fixWinOsPathSep = require(`../src/fixWinOsPathSep`);
2+
const loader = require('../src/index.js');
3+
4+
const mockContext = {
5+
loader: {
6+
_module: {
7+
NormalModule: {
8+
issuer: {
9+
ContextModule: {
10+
debugId: 36,
11+
regExp: /\.js$/,
12+
}
13+
}
14+
}
15+
}
16+
}
17+
}
18+
19+
function cutSpaces(str) {
20+
return str.replace(/[\s\n\r\t]*/g, '');
21+
}
22+
23+
describe('Test winOs (roughly)', () => {
24+
it('fixWinOsPathSep should do its job correctly', () => {
25+
expect(fixWinOsPathSep('/path/to/project')).toBe('/path/to/project')
26+
expect(fixWinOsPathSep('\\path\\to\\project')).toBe('/path/to/project')
27+
expect(fixWinOsPathSep('C:\\path\\to\\project')).toBe('C:/path/to/project')
28+
})
29+
30+
it('Final query should not contain query options', () => {
31+
function errorHandler(e) {
32+
throw e;
33+
}
34+
const context = {
35+
...mockContext,
36+
query: {
37+
data: {
38+
loader: 'babel-loader',
39+
options: {
40+
output: 'C:\\root\\the_folder_name_should_not_be_fixed'
41+
}
42+
}
43+
},
44+
resourcePath: './index.js',
45+
emitError: errorHandler
46+
}
47+
const result = loader.pitch.call(
48+
context
49+
)
50+
expect(cutSpaces(result).includes('the_folder_name_should_not_be_fixed')).toBe(false);
51+
})
52+
53+
it('Windows-style separators should be replaced, but inline query options does not', () => {
54+
function errorHandler(e) {
55+
throw e;
56+
}
57+
const context = {
58+
...mockContext,
59+
query: {
60+
data: 'babel-loader?saveto=C:\\root\\the_folder_name_should_not_be_fixed'
61+
},
62+
resourcePath: './index.js',
63+
emitError: errorHandler
64+
}
65+
const result = loader.pitch.call(
66+
context
67+
)
68+
expect(cutSpaces(result)).toBe(`module.exports={};module.exports["data"]=require('!babel-loader?saveto=C:\\root\\the_folder_name_should_not_be_fixed!./index.js');`);
69+
})
70+
});

lib/index.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

lib/log.txt

Lines changed: 0 additions & 48 deletions
This file was deleted.

lib/normalizeLoader.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/querifyLoader.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)