repo-tools: run prettier on sql reports
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -184,11 +184,13 @@ async function runSingleSqlExtraction(
|
||||
}
|
||||
}
|
||||
|
||||
const report = generateSqlReport({
|
||||
reportName,
|
||||
failedDownMigration,
|
||||
schemaInfo,
|
||||
});
|
||||
const report = prettyReport(
|
||||
generateSqlReport({
|
||||
reportName,
|
||||
failedDownMigration,
|
||||
schemaInfo,
|
||||
}),
|
||||
);
|
||||
|
||||
const reportPath = cliPaths.resolveTargetRoot(
|
||||
targetDir,
|
||||
@@ -225,3 +227,17 @@ async function runSingleSqlExtraction(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function prettyReport(content: string): string {
|
||||
try {
|
||||
const prettier = require('prettier') as typeof import('prettier');
|
||||
|
||||
const config = prettier.resolveConfig.sync(cliPaths.targetRoot) ?? {};
|
||||
return prettier.format(content, {
|
||||
...config,
|
||||
parser: 'markdown',
|
||||
});
|
||||
} catch (e) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user