mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-22 21:35:08 +00:00
fix edge case when ~/package.json exists with type: module
This commit is contained in:
parent
670c62267e
commit
d39c54b3ee
1 changed files with 4 additions and 3 deletions
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { mkdirSync } from "fs";
|
import { mkdirSync } from "fs";
|
||||||
import { access, constants as FsConstants } from "fs/promises";
|
import { access, constants as FsConstants, writeFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
import { USER_AGENT, VENCORD_FILES_DIR } from "../constants";
|
import { USER_AGENT, VENCORD_FILES_DIR } from "../constants";
|
||||||
|
@ -63,7 +63,8 @@ const existsAsync = (path: string) =>
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
|
|
||||||
export async function isValidVencordInstall(dir: string) {
|
export async function isValidVencordInstall(dir: string) {
|
||||||
return Promise.all(FILES_TO_DOWNLOAD.map(f => existsAsync(join(dir, f)))).then(arr => !arr.includes(false));
|
const results = await Promise.all(["package.json", ...FILES_TO_DOWNLOAD].map(f => existsAsync(join(dir, f))));
|
||||||
|
return results.every(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ensureVencordFiles() {
|
export async function ensureVencordFiles() {
|
||||||
|
@ -71,5 +72,5 @@ export async function ensureVencordFiles() {
|
||||||
|
|
||||||
mkdirSync(VENCORD_FILES_DIR, { recursive: true });
|
mkdirSync(VENCORD_FILES_DIR, { recursive: true });
|
||||||
|
|
||||||
await downloadVencordFiles();
|
await Promise.all([downloadVencordFiles(), writeFile(join(VENCORD_FILES_DIR, "package.json"), "{}")]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue