MCPcopy Create free account
hub / github.com/chhoumann/quickadd / linkPluginFile

Function linkPluginFile

scripts/provision-obsidian-e2e-vault.mjs:150–169  ·  view source on GitHub ↗
(sourcePath, destinationPath, force)

Source from the content-addressed store, hash-verified

148}
149
150async function linkPluginFile(sourcePath, destinationPath, force) {
151 const existing = await pathExists(destinationPath);
152 if (existing && force) {
153 await fs.unlink(destinationPath);
154 } else if (existing) {
155 const stat = await fs.lstat(destinationPath);
156 if (!stat.isSymbolicLink()) {
157 throw new Error(`${destinationPath} exists and is not a symlink. Use --force after reviewing it.`);
158 }
159
160 const currentTarget = await fs.readlink(destinationPath);
161 if (path.resolve(path.dirname(destinationPath), currentTarget) === sourcePath) {
162 return;
163 }
164
165 throw new Error(`${destinationPath} points at ${currentTarget}. Use --force to relink it.`);
166 }
167
168 await fs.symlink(sourcePath, destinationPath);
169}
170
171export async function provisionVault(options) {
172 await assertRequiredPluginFiles(options.worktreePath);

Callers 1

provisionVaultFunction · 0.85

Calls 3

dirnameMethod · 0.80
pathExistsFunction · 0.70
resolveMethod · 0.45

Tested by

no test coverage detected