Skip to content

Commit 6fc6874

Browse files
fix: context with symbols (#94)
1 parent 04fc3ca commit 6fc6874

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

src/utils.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1+
import { join } from 'path';
12
import { statSync } from 'fs';
23

34
// @ts-ignore
45
import arrify from 'arrify';
56

6-
const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
7-
87
/**
98
* @param {string|string[]} files
109
* @param {string} context
1110
* @returns {string[]}
1211
*/
1312
export function parseFiles(files, context) {
14-
return arrify(files).map(
15-
(/** @type {string} */ file) =>
16-
`${replaceBackslashes(context).replace(
17-
UNESCAPED_GLOB_SYMBOLS_RE,
18-
'\\$2'
19-
)}/${replaceBackslashes(file)}`
13+
return arrify(files).map((/** @type {string} */ file) =>
14+
replaceBackslashes(join(context, file))
2015
);
2116
}
2217

test/fixtures/[symbols]/error.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var foo = stuff
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./error');

test/symbols.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { join } from 'path';
2+
3+
import pack from './utils/pack';
4+
5+
describe('symbols', () => {
6+
afterEach(() => {
7+
jest.restoreAllMocks();
8+
});
9+
10+
it('should return error', (done) => {
11+
const compiler = pack(
12+
'symbols',
13+
{},
14+
{ context: join(__dirname, 'fixtures/[symbols]') }
15+
);
16+
17+
compiler.run((err, stats) => {
18+
expect(err).toBeNull();
19+
expect(stats.hasWarnings()).toBe(false);
20+
expect(stats.hasErrors()).toBe(true);
21+
done();
22+
});
23+
});
24+
});

0 commit comments

Comments
 (0)