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

Replace rimraf with native rm #297

Merged
merged 10 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ updates:
- dependency-name: 'glob'
update-types:
- version-update:semver-major
- dependency-name: 'rimraf'
update-types:
- version-update:semver-major
- dependency-name: 'which'
update-types:
- version-update:semver-major
Expand Down
4 changes: 3 additions & 1 deletion lib/autofix.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ function askConfirmationToFixWithOptions(options, app, elmVersion) {
modifiedElmJson = file;
}

return await FS.writeFile(filePath, file.source).then(() => file);
await FS.writeFile(filePath, file.source);

return file;
})
);

Expand Down
10 changes: 4 additions & 6 deletions lib/elm-app-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ if (parentPort) {
* @returns {void}
*/
function subscribe(parentPort) {
parentPort.on('message', ([port, data]) => {
parentPort.on('message', async ([port, data]) => {
if (port === 'startReview' || port === 'startGeneratingSuppressions') {
loadCachePromise.then(() => {
app.ports[port].send(data);
});
} else {
app.ports[port].send(data);
await loadCachePromise;
}

app.ports[port].send(data);
});

app.ports.requestReadingFiles.subscribe((data) => {
Expand Down
16 changes: 13 additions & 3 deletions lib/fs-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
const fs = require('graceful-fs');
const fsp = fs.promises;
const {rimraf} = require('rimraf');

/**
* Read a JSON file.
Expand Down Expand Up @@ -77,6 +76,17 @@ function mkdirpSync(dir) {
fs.mkdirSync(dir, {recursive: true});
}

/**
* @param {fs.PathLike} file
*/
async function remove(file) {
await fsp.rm(
file,
// Rimraf compatibility:
{recursive: true, force: true, maxRetries: 10}
lishaduck marked this conversation as resolved.
Show resolved Hide resolved
);
}

module.exports = {
readFile,
readJsonFile,
Expand All @@ -88,9 +98,9 @@ module.exports = {
mkdirp,
mkdirpSync,

readdir: fsp.readdir,
remove,

remove: rimraf,
readdir: fsp.readdir,

stat: fsp.stat
};
2 changes: 1 addition & 1 deletion lib/suppressed-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Please check that ${chalk.greenBright('elm-review')} has write permissions to th
return null;
}

return await FS.remove(filePath);
await FS.remove(filePath);
});
await Promise.all(writePromises);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/types/state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {ElmFile, Readme, Source} from './content.js';
import type {ElmFile, File, Readme} from './content.js';
import type {Path} from './path.js';

export type Model = {
Expand All @@ -23,7 +23,7 @@ export type ExitRequest = {

export type AppUnsubscribeFunction = () => void;

export type FilesProposedByCurrentFix = {path: Path; source: Source}[];
export type FilesProposedByCurrentFix = File[];

export type FileId = string;

Expand Down
23 changes: 0 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"ora": "^5.4.0",
"path-key": "^3.1.1",
"prompts": "^2.2.1",
"rimraf": "^5.0.0",
"strip-ansi": "^6.0.0",
"terminal-link": "^2.1.1",
"tinyglobby": "^0.2.10",
Expand Down