(sourcePath, destinationPath, force)
| 148 | } |
| 149 | |
| 150 | async 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 | |
| 171 | export async function provisionVault(options) { |
| 172 | await assertRequiredPluginFiles(options.worktreePath); |
no test coverage detected