fix(providence-analytics): clean output extend-docs

This commit is contained in:
Thijs Louisse 2020-08-10 19:25:15 +02:00
parent a3297d4b90
commit 7471f8cc7e
3 changed files with 17 additions and 5 deletions

View file

@ -2,6 +2,14 @@
'providence-analytics': minor 'providence-analytics': minor
--- ---
Allowlist mode: autodetects whether analyzed repository is a "git" or "npm" (published artifact) repository. Allowlist modes
Via the cli `--allowlist-mode 'npm|git|all'` and `--allowlist-mode-reference 'npm|git|all'` can be
configured to override the autodetected mode. #### Features
- Allowlist mode: autodetects whether analyzed repository is a "git" or "npm" (published artifact) repository.
Via the cli `--allowlist-mode 'npm|git|all'` and `--allowlist-mode-reference 'npm|git|all'` can be
configured to override the autodetected mode.
#### Bugfixes
- Clean output extend-docs: strings like '[no-dependency]' will not end up in aggregated result

View file

@ -178,4 +178,5 @@ module.exports = {
spawnProcess, spawnProcess,
installDeps, installDeps,
pathsArrayFromCollectionName, pathsArrayFromCollectionName,
flatten,
}; };

View file

@ -5,6 +5,7 @@ const { performance } = require('perf_hooks');
const { providence } = require('../program/providence.js'); const { providence } = require('../program/providence.js');
const { QueryService } = require('../program/services/QueryService.js'); const { QueryService } = require('../program/services/QueryService.js');
const { LogService } = require('../program/services/LogService.js'); const { LogService } = require('../program/services/LogService.js');
const { flatten } = require('./cli-helpers.js');
async function launchProvidenceWithExtendDocs({ async function launchProvidenceWithExtendDocs({
referenceProjectPaths, referenceProjectPaths,
@ -35,11 +36,13 @@ async function launchProvidenceWithExtendDocs({
); );
const outputFilePath = pathLib.join(outputFolder, 'providence-extend-docs-data.json'); const outputFilePath = pathLib.join(outputFolder, 'providence-extend-docs-data.json');
const queryOutputs = results.map(result => result.queryOutput).flat(); const queryOutputs = flatten(
results.map(result => result.queryOutput).filter(o => typeof o !== 'string'), // filter out '[no-dependency]' etc.
);
if (fs.existsSync(outputFilePath)) { if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath); fs.unlinkSync(outputFilePath);
} }
fs.writeFile(outputFilePath, JSON.stringify(queryOutputs), err => { fs.writeFile(outputFilePath, JSON.stringify(queryOutputs, null, 2), err => {
if (err) { if (err) {
throw err; throw err;
} }