MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / canCreateLink

Function canCreateLink

__tests__/ui-trails.test.ts:160–175  ·  view source on GitHub ↗

* Whether this machine can create a link of `type`. A Windows junction needs no * privilege; a symbolic link there needs Developer Mode or admin rights. Where * one can't be made, its tests are skipped, with the reason in their name.

(type: 'file' | 'dir' | 'junction')

Source from the content-addressed store, hash-verified

158 * one can't be made, its tests are skipped, with the reason in their name.
159 */
160function canCreateLink(type: 'file' | 'dir' | 'junction'): boolean {
161 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-link-probe-'));
162 const target = path.join(dir, 'target');
163 const link = path.join(dir, 'link');
164 try {
165 if (type === 'file') fs.writeFileSync(target, '');
166 else fs.mkdirSync(target);
167 fs.symlinkSync(target, link, type);
168 return true;
169 } catch {
170 return false;
171 } finally {
172 removeLink(link);
173 fs.rmSync(dir, { recursive: true, force: true });
174 }
175}
176
177/** A `.codegraph/ui` link can be a junction or a directory symlink on Windows. */
178const DIR_LINKS = (process.platform === 'win32' ? ['junction', 'dir'] : ['dir']) as Array<

Callers 1

ui-trails.test.tsFile · 0.85

Calls 2

removeLinkFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected