@code-pushup/utils 0.16.8 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -1
- package/package.json +1 -1
- package/src/index.d.ts +1 -1
- package/src/lib/file-system.d.ts +1 -0
package/index.js
CHANGED
|
@@ -552,7 +552,7 @@ import { join as join2 } from "node:path";
|
|
|
552
552
|
// packages/utils/src/lib/file-system.ts
|
|
553
553
|
import { bundleRequire } from "bundle-require";
|
|
554
554
|
import chalk from "chalk";
|
|
555
|
-
import { mkdir, readFile, readdir, stat } from "node:fs/promises";
|
|
555
|
+
import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
|
|
556
556
|
import { join } from "node:path";
|
|
557
557
|
|
|
558
558
|
// packages/utils/src/lib/formatting.ts
|
|
@@ -691,6 +691,11 @@ async function ensureDirectoryExists(baseDir) {
|
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
+
async function removeDirectoryIfExists(dir) {
|
|
695
|
+
if (await directoryExists(dir)) {
|
|
696
|
+
await rm(dir, { recursive: true, force: true });
|
|
697
|
+
}
|
|
698
|
+
}
|
|
694
699
|
function logMultipleFileResults(fileResults, messagePrefix) {
|
|
695
700
|
const succeededCallback = (result) => {
|
|
696
701
|
const [fileName, size] = result.value;
|
|
@@ -1754,6 +1759,7 @@ export {
|
|
|
1754
1759
|
portalCommitDashboardLink,
|
|
1755
1760
|
readJsonFile,
|
|
1756
1761
|
readTextFile,
|
|
1762
|
+
removeDirectoryIfExists,
|
|
1757
1763
|
scoreReport,
|
|
1758
1764
|
slugify,
|
|
1759
1765
|
sortReport,
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { exists } from '@code-pushup/models';
|
|
2
2
|
export { ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, } from './lib/execute-process';
|
|
3
|
-
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, } from './lib/file-system';
|
|
3
|
+
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, directoryExists, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, removeDirectoryIfExists, } from './lib/file-system';
|
|
4
4
|
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateIssueMessage, truncateText, truncateTitle, } from './lib/formatting';
|
|
5
5
|
export { getLatestCommit, git, validateCommitData } from './lib/git';
|
|
6
6
|
export { groupByStatus } from './lib/group-by-status';
|
package/src/lib/file-system.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function readJsonFile<T = unknown>(path: string): Promise<T>;
|
|
|
4
4
|
export declare function fileExists(path: string): Promise<boolean>;
|
|
5
5
|
export declare function directoryExists(path: string): Promise<boolean>;
|
|
6
6
|
export declare function ensureDirectoryExists(baseDir: string): Promise<void>;
|
|
7
|
+
export declare function removeDirectoryIfExists(dir: string): Promise<void>;
|
|
7
8
|
export type FileResult = readonly [string] | readonly [string, number];
|
|
8
9
|
export type MultipleFileResults = PromiseSettledResult<FileResult>[];
|
|
9
10
|
export declare function logMultipleFileResults(fileResults: MultipleFileResults, messagePrefix: string): void;
|