@augment-vir/node
Version:
A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.
26 lines (25 loc) • 1.16 kB
JavaScript
import { awaitedForEach, retry, wait } from '@augment-vir/common';
import { interpolationSafeWindowsPath } from '../augments/path/os-path.js';
import { runShellCommand } from '../augments/terminal/shell.js';
import { generatedPrismaClientDirPath, notCommittedDirPath, testPrismaMigrationsDirPath, } from '../file-paths.mock.js';
const pathsToDelete = [
generatedPrismaClientDirPath,
notCommittedDirPath,
testPrismaMigrationsDirPath,
];
export async function clearTestDatabaseOutputs() {
await retry(10, async () => {
await wait({ seconds: 1 });
await awaitedForEach(pathsToDelete, async (pathToDelete) => {
/**
* This way of deleting files is required for Windows tests running on GitHub Actions.
* Otherwise, we get the following error:
*
* EPERM: operation not permitted, unlink 'D:\a\augment-vir\augment-vir\packages\node\node_modules\.prisma\query_engine-windows.dll.node'
*/
await runShellCommand(`rm -rf ${interpolationSafeWindowsPath(pathToDelete)}`, {
rejectOnError: true,
});
});
});
}