fix(providence): windows compatibility
This commit is contained in:
parent
306d57f57d
commit
b90ed14234
4 changed files with 21 additions and 4 deletions
|
|
@ -2,4 +2,5 @@
|
||||||
'providence-analytics': patch
|
'providence-analytics': patch
|
||||||
---
|
---
|
||||||
|
|
||||||
correctly dedupe match-imports exportSpecifiers
|
- correctly dedupe match-imports exportSpecifiers
|
||||||
|
- windows compatibility
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,12 @@ async function appendProjectDependencyPaths(rootPaths, matchPattern, modes = ['n
|
||||||
let matchFn;
|
let matchFn;
|
||||||
if (matchPattern) {
|
if (matchPattern) {
|
||||||
if (matchPattern.startsWith('/') && matchPattern.endsWith('/')) {
|
if (matchPattern.startsWith('/') && matchPattern.endsWith('/')) {
|
||||||
matchFn = (_, d) => new RegExp(matchPattern.slice(1, -1)).test(d);
|
matchFn = (_, d) => {
|
||||||
|
const reString = matchPattern.slice(1, -1);
|
||||||
|
const result = new RegExp(reString).test(d);
|
||||||
|
LogService.debug(`[appendProjectDependencyPaths]: /${reString}/.test(${d} => ${result})`);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
LogService.error(
|
LogService.error(
|
||||||
`[appendProjectDependencyPaths] Please provide a matchPattern enclosed by '/'. Found: ${matchPattern}`,
|
`[appendProjectDependencyPaths] Please provide a matchPattern enclosed by '/'. Found: ${matchPattern}`,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ const pathLib = require('path');
|
||||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
||||||
const { LogService } = require('../services/LogService.js');
|
const { LogService } = require('../services/LogService.js');
|
||||||
const { memoizeAsync } = require('./memoize.js');
|
const { memoizeAsync } = require('./memoize.js');
|
||||||
|
const { toPosixPath } = require('./to-posix-path.js');
|
||||||
|
|
||||||
const fakePluginContext = {
|
const fakePluginContext = {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -51,7 +52,7 @@ async function resolveImportPath(importee, importer, opts = {}) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return result.id;
|
return toPosixPath(result.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -484,8 +484,18 @@ describe('CLI helpers', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows a regex filter', async () => {
|
it('allows a regex filter', async () => {
|
||||||
const result = await appendProjectDependencyPaths(['/mocked/path/example-project'], '/b$/');
|
const result = await appendProjectDependencyPaths(
|
||||||
|
['/mocked/path/example-project'],
|
||||||
|
'/^dependency-/',
|
||||||
|
);
|
||||||
expect(result).to.eql([
|
expect(result).to.eql([
|
||||||
|
'/mocked/path/example-project/node_modules/dependency-a',
|
||||||
|
'/mocked/path/example-project/bower_components/dependency-b',
|
||||||
|
'/mocked/path/example-project',
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result2 = await appendProjectDependencyPaths(['/mocked/path/example-project'], '/b$/');
|
||||||
|
expect(result2).to.eql([
|
||||||
'/mocked/path/example-project/bower_components/dependency-b',
|
'/mocked/path/example-project/bower_components/dependency-b',
|
||||||
'/mocked/path/example-project',
|
'/mocked/path/example-project',
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue