Skip to content

Commit 7ed962f

Browse files
fix: create outputs dir
1 parent 0924673 commit 7ed962f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tools/spectral/ipa/metrics/config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import path from 'path';
22
import { fileURLToPath } from 'url';
33

44
const dirname = path.dirname(fileURLToPath(import.meta.url));
5-
const outputDir = path.join(dirname, 'outputs');
65
const rootDir = path.resolve(dirname, '../../../../');
76

87
const config = {
98
defaultOasFilePath: path.join(rootDir, 'openapi', 'v2.json'),
109
defaultRulesetFilePath: path.join(dirname, '..', 'ipa-spectral.yaml'),
1110
defaultCollectorResultsFilePath: path.join(dirname, 'ipa-collector-results-combined.log'),
12-
defaultMetricCollectionResultsFilePath: path.join(outputDir, 'metric-collection-results.json'),
13-
defaultSpectralReportFile: path.join(outputDir, 'spectral-report.xml'),
14-
defaultSpectralOutputFile: path.join(outputDir, 'spectral-output.txt'),
11+
defaultOutputsDir: path.join(dirname, 'outputs'),
1512
};
1613

14+
config.defaultMetricCollectionResultsFilePath = path.join(config.defaultOutputsDir, 'metric-collection-results.json');
15+
config.defaultSpectralReportFile = path.join(config.defaultOutputsDir, 'spectral-report.xml');
16+
config.defaultSpectralOutputFile = path.join(config.defaultOutputsDir, 'spectral-output.txt');
17+
1718
export default config;

tools/spectral/ipa/metrics/metricCollection.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ async function runMetricCollectionJob(oasFilePath = config.defaultOasFilePath) {
4242
const args = process.argv.slice(2);
4343
const customOasFile = args[0];
4444

45+
if(!fs.existsSync(config.defaultOutputsDir)){
46+
fs.mkdirSync('outputs');
47+
console.log(`Output directory created successfully`);
48+
}
49+
4550
const result = spawnSync(
4651
'spectral',
4752
[

0 commit comments

Comments
 (0)