Skip to content

Commit

Permalink
refactor: improved namings
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Jun 12, 2024
1 parent 6a9defb commit d4ffdca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions utils/map-inputs-outputs.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import path from 'node:path';

export function mapSourceToOutputFiles({ rootDir, outdir, sourceFiles, outputFiles }) {
const sourceMap = sourceFiles.reduce((acc, rawSourceFile) => {
const sourcesMap = sourceFiles.reduce((acc, rawSourceFile) => {
const sourceFile = path.relative(rootDir, rawSourceFile);
const sourceFileParts = sourceFile.split('.');
const sourceFileBase = sourceFileParts.slice(0, -1).join('.');
acc[sourceFileBase] = rawSourceFile;
return acc;
}, {});

const outputMap = outputFiles.reduce((acc, rawOutputFile) => {
const outputsMap = outputFiles.reduce((acc, rawOutputFile) => {
const outputFile = path.relative(outdir, rawOutputFile);
const outputFileParts = outputFile.split('.');
const outputFileBase = adaptTwoDots(outputFileParts.slice(0, -1).join('.'));
Expand All @@ -18,10 +18,10 @@ export function mapSourceToOutputFiles({ rootDir, outdir, sourceFiles, outputFil
}, {});

const result = {};
for (const key of Object.keys(sourceMap)) {
if (outputMap[key]) {
const sourcePath = path.resolve(sourceMap[key]);
const outputPath = path.resolve(outputMap[key]);
for (const key of Object.keys(sourcesMap)) {
if (outputsMap[key]) {
const sourcePath = path.resolve(sourcesMap[key]);
const outputPath = path.resolve(outputsMap[key]);
result[sourcePath] = outputPath;
}
}
Expand Down

0 comments on commit d4ffdca

Please sign in to comment.