Skip to content

Update rimraf to a non-deprecated version but that still supports Node18 #186

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@types/mkdirp": "^1.0.2",
"@types/node": "^18.11.9",
"@types/prettier": "^2.7.1",
"@types/rimraf": "^3.0.2",
"@types/rimraf": "^4.0.5",
"@types/yargs": "^15.0.5",
"common-tags": "^1.8.2",
"dotenv": "^16.0.3",
Expand All @@ -67,7 +67,7 @@
"native-fetch": "^4.0.2",
"prettier": "^2.8.0",
"qs": "^6.11.0",
"rimraf": "^2.6.3",
"rimraf": "^4.4.1",
"undici": "^5.22.0",
"yargs": "^15.3.1"
},
Expand Down
35 changes: 14 additions & 21 deletions cli/src/helpers/files.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import { promises as fs } from 'fs'
import mkdirp from 'mkdirp'
import { resolve } from 'path'
import rimraf from 'rimraf'
import { promises as fs } from "fs";
import mkdirp from "mkdirp";
import { resolve } from "path";
import { rimraf } from "rimraf";

export const ensurePath = async (path: string[], clear: boolean = false) => {
if (clear)
await new Promise((rs, rj) => {
rimraf(resolve(...path), (err) => {
if (err) rj(err)
else rs(undefined)
})
})

await mkdirp(resolve(...path))
}
if (clear) await rimraf(resolve(...path));
await mkdirp(resolve(...path));
};

export const readFileFromPath = (path: string[]) =>
fs.readFile(resolve(...path)).then((b) => b.toString())
fs.readFile(resolve(...path)).then((b) => b.toString());

export const writeFileToPath = async (path: string[], content: string) => {
const folder = resolve(...path, '..')
await fs.mkdir(folder, { recursive: true })
await fs.writeFile(resolve(...path), content)
}
const folder = resolve(...path, "..");
await fs.mkdir(folder, { recursive: true });
await fs.writeFile(resolve(...path), content);
};

export const readFilesAndConcat = (files: string[]) =>
Promise.all(files.map((file) => readFileFromPath([file]))).then(
(contents) => contents.join('\n'),
)
(contents) => contents.join("\n")
);