Skip to content

Commit

Permalink
Improved rimraf
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Dec 12, 2023
1 parent cfcd301 commit 8616fd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, describe, it, beforeEach, beforeAll, afterAll } from '@jest/globals';
import { promises as fsPromises } from 'fs';
import { rimraf } from 'rimraf';
import { resolve } from 'path';
import { rimraf, copyAll } from './io';
import { copyAll } from './io';
import { createTestContextFactory } from './context';
import { TestEnvironment, TestEnvironmentRef } from './types';

Expand Down Expand Up @@ -47,7 +48,9 @@ export const isCleaning = process.env.CLEANUP === 'yes';
export async function prepareTests(area: string): Promise<TestEnvironment> {
const dir = resolve(outdir, area);
const createTestContext = createTestContextFactory(dir);
const destroyTestContext = () => rimraf(dir);
const destroyTestContext = async () => {
await rimraf(dir);
};
await rimraf(dir);
await fsPromises.mkdir(dir, { recursive: true });
return {
Expand All @@ -71,7 +74,7 @@ export function runTests(area: string, cb: (ref: TestEnvironmentRef) => void) {
},
test(prefix, description, flags, cb) {
const noTemplate = flags.includes('#empty');
const features = flags.filter(flag => !flag.startsWith('#'));
const features = flags.filter((flag) => !flag.startsWith('#'));
// either we run in the "standard repo" (i.e., not as a bundler plugin)
// or we need to have some bundler-features defined (and all features should be available from the bundler - otherwise its broken by default)
const canRun = !isBundlerPlugin || (features.length > 0 && features.every((s) => bundlerFeatures.includes(s)));
Expand Down
5 changes: 1 addition & 4 deletions src/utils/io.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import * as rimrafClassic from 'rimraf';
import { rimraf } from 'rimraf';
import { promises as fsPromises } from 'fs';
import { resolve, relative, sep, posix } from 'path';
import { promisify } from 'util';

export const rimraf = promisify(rimrafClassic.default || rimrafClassic);

export async function cleanDir(dirPath: string) {
await rimraf(dirPath);
Expand Down

0 comments on commit 8616fd8

Please sign in to comment.