mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
fix: path not allowed on the configured scope
This commit is contained in:
parent
d93079f682
commit
a7c4545dbf
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 };
|
||||
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 file = await join(isRoot ? '' : root, path);
|
||||
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user