Skip to content

Commit 4237b7e

Browse files
committed
#102: pass output path to findVariations and buildRecipientEndorsementPath
1 parent 69145d3 commit 4237b7e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

common.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ const buildRecipientEndorsementPath = ({
183183
recipientUoi,
184184
endorsementName,
185185
version,
186-
currentOrArchived = 'current'
186+
currentOrArchived = 'current',
187+
outputPath
187188
} = {}) => {
188189
//TODO: clean up
189190
if (!resultsPath) throw Error('resultsPath is required!');
@@ -197,7 +198,7 @@ const buildRecipientEndorsementPath = ({
197198
if (!isValidVersion(endorsementName, version)) throw new Error(`Invalid version: ${version}`);
198199

199200
return join(
200-
process.cwd(),
201+
outputPath || process.cwd(),
201202
resultsPath,
202203
`${endorsementName}-${version}`,
203204
`${providerUoi}-${providerUsi}`,

lib/certification/data-dictionary/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ const runDDTests = async ({
215215
providerUsi,
216216
recipientUoi,
217217
endorsementName,
218-
version
218+
version,
219+
outputPath
219220
});
220221
const pathToConfigFile = join(RECIPIENT_PATH, CONFIG_FILE_NAME);
221222

@@ -465,7 +466,7 @@ const getDataDictionaryTestSteps = ({
465466

466467
testSteps.push(
467468
async () => {
468-
const { variations } = await findVariations({ pathToMetadataReportJson, fromCli, strictMode });
469+
const { variations } = await findVariations({ pathToMetadataReportJson, fromCli, strictMode, outputPath });
469470
if (strictMode && Object.values(variations).some(variation => variation?.length)) {
470471
throw new Error('Found variations during testing!');
471472
}

lib/variations/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const humanizeDuration = require('humanize-duration');
99
const { convertVariationsCsvToJson } = require('./utils');
1010
const { readFileSync, writeFileSync } = require('fs');
1111
const { inflateSync } = require('node:zlib');
12+
const path = require('node:path');
1213

1314
const {
1415
REFERENCE_METADATA_URL,
@@ -784,7 +785,8 @@ const findVariations = async ({
784785
fuzziness = DEFAULT_FUZZINESS,
785786
version = DEFAULT_DD_VERSION,
786787
useSuggestions = true,
787-
fromCli = false
788+
fromCli = false,
789+
outputPath
788790
} = {}) => {
789791
// custom logger
790792
const { LOG, LOG_ERROR } = getLoggers(fromCli);
@@ -827,7 +829,10 @@ const findVariations = async ({
827829
const report = await computeVariations(args);
828830

829831
if (Object.values(report?.variations ?? {}).some(variation => variation?.length)) {
830-
await writeFile(CERTIFICATION_FILES.VARIATIONS_REPORT, Buffer.from(JSON.stringify(report, null, 2)));
832+
const variationsOutputPath = outputPath
833+
? path.join(outputPath, CERTIFICATION_FILES.VARIATIONS_REPORT)
834+
: CERTIFICATION_FILES.VARIATIONS_REPORT;
835+
await writeFile(variationsOutputPath, Buffer.from(JSON.stringify(report, null, 2)));
831836
LOG(`Results saved to '${VARIATIONS_RESULTS_FILE}'`);
832837
}
833838

0 commit comments

Comments
 (0)