mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
fix: path not allowed on the configured scope
This commit is contained in:
4
src/utils.ts
vendored
4
src/utils.ts
vendored
@@ -52,12 +52,12 @@ export const readJSON = async (path: string, opts: readJSONOpts = {}) => {
|
|||||||
|
|
||||||
type writeJSONOpts = { dir?: string, isRoot?: boolean };
|
type writeJSONOpts = { dir?: string, isRoot?: boolean };
|
||||||
export const writeJSON = async (path: string, data: Record<string, any>, opts: writeJSONOpts = {}) => {
|
export const writeJSON = async (path: string, data: Record<string, any>, opts: writeJSONOpts = {}) => {
|
||||||
const { isRoot = false, dir = '' } = opts;
|
const { isRoot = false } = opts;
|
||||||
const root = await chatRoot();
|
const root = await chatRoot();
|
||||||
const file = await join(isRoot ? '' : root, path);
|
const file = await join(isRoot ? '' : root, path);
|
||||||
|
|
||||||
if (isRoot && !await exists(await dirname(file))) {
|
if (isRoot && !await exists(await dirname(file))) {
|
||||||
await createDir(await join('.chatgpt', dir), { dir: BaseDirectory.Home });
|
await createDir(await dirname(file), { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
await writeTextFile(file, JSON.stringify(data, null, 2));
|
await writeTextFile(file, JSON.stringify(data, null, 2));
|
||||||
|
|||||||
Reference in New Issue
Block a user