1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: Make creation of symlinks not fail when parent directory does not exist

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2023-04-21 16:01:09 +03:00
parent 96ce667cbd
commit 603afc19a7
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A

View File

@ -1,9 +1,15 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import fse from "fs-extra"; import fse from "fs-extra";
import { dirname } from "path";
export type CreateSymlink = (target: string, path: string, type: "dir" | "file") => Promise<void>; export type CreateSymlink = (target: string, path: string, type: "dir" | "file") => Promise<void>;
export const createSymlinkInjectable = getInjectable({ export const createSymlinkInjectable = getInjectable({
id: "create-symlink", id: "create-symlink",
instantiate: (): CreateSymlink => fse.symlink,
instantiate: (): CreateSymlink => async (target, path, type) => {
await fse.ensureDir(dirname(path));
return fse.symlink(target, path, type);
},
}); });