Skip to content

Commit

Permalink
fix: linked modules paths (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Jan 18, 2024
1 parent a782653 commit 83862ab
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions __fixtures__/linked-local-reporter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = class LinkedReporter {};
6 changes: 6 additions & 0 deletions __fixtures__/linked-local-reporter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "linked-local-reporter",
"version": "1.0.0",
"main": "index.js",
"private": true
}
1 change: 1 addition & 0 deletions __fixtures__/simple-project/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
setupFilesAfterEnv: ['lodash/noop'],
reporters: [
'default',
'linked-local-reporter',
'<rootDir>/customReporter.js',
],
testMatch: [
Expand Down
1 change: 1 addition & 0 deletions __fixtures__/simple-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"jest": "^29.5.0",
"jest-environment-emit": "^1.0.3",
"jest-allure2-reporter": "^2.0.0-beta.1",
"linked-local-reporter": "../linked-local-reporter",
"lodash": "^4.17.21"
}
}
12 changes: 11 additions & 1 deletion utils/map-inputs-outputs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function mapSourceToOutputFiles({ rootDir, outdir, sourceFiles, outputFil
const outputMap = outputFiles.reduce((acc, rawOutputFile) => {
const outputFile = path.relative(outdir, rawOutputFile);
const outputFileParts = outputFile.split('.');
const outputFileBase = outputFileParts.slice(0, -1).join('.');
const outputFileBase = adaptTwoDots(outputFileParts.slice(0, -1).join('.'));
acc[outputFileBase] = rawOutputFile;
return acc;
}, {});
Expand All @@ -28,3 +28,13 @@ export function mapSourceToOutputFiles({ rootDir, outdir, sourceFiles, outputFil

return result;
}

function adaptTwoDots(filePath) {
const segments = filePath.split(path.sep);
return segments.map(convertTwoDots).join(path.sep);
}

function convertTwoDots(segment) {
return segment === '_.._' ? '..' : segment;

}

0 comments on commit 83862ab

Please sign in to comment.