Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Handle removing non-empty directories and non-existing paths in cache #23279

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 6 additions & 10 deletions packages/nx/src/tasks-runner/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { workspaceRoot } from '../utils/workspace-root';
import { mkdir, mkdirSync, pathExists, readFile, writeFile } from 'fs-extra';
import { mkdir, mkdirSync, pathExists, readFile, writeFile, remove as fsRemove } from 'fs-extra';
import { join } from 'path';
import { performance } from 'perf_hooks';
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
Expand Down Expand Up @@ -203,15 +203,11 @@ export class Cache {
}

private async remove(path: string): Promise<void> {
const { remove } = require('../native');
return new Promise((res, rej) => {
try {
remove(path);
res();
} catch (e) {
rej(e);
}
});
try {
fsRemove(path);
} catch (e) {
// It's okay if this fails, the OS will clean it up eventually
}
}

private async getFromLocalDir(task: Task) {
Expand Down