File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { Package } from "../types.ts"
55import install from "./install.ts"
66import link from "./link.ts" ;
77
8- Deno . test ( "link() " , async runner => {
8+ Deno . test ( "prefab. link" , async runner => {
99 const pkg : Package = {
1010 project : "tea.xyz/brewkit" ,
1111 version : new SemVer ( "0.30.0" )
@@ -16,7 +16,7 @@ Deno.test("link()", async runner => {
1616
1717 const installation = await install ( pkg )
1818 await link ( installation )
19- await link ( installation ) // calling twice works
19+ await link ( installation ) // test that calling twice serially works
2020
2121 /// test symlinks work
2222 assert ( installation . path . parent ( ) . join ( "v*" ) . isDirectory ( ) )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import SemVer, * as semver from "../utils/semver.ts"
22import { Package , Installation } from "../types.ts"
33import useCellar from "../hooks/useCellar.ts"
44import { panic } from "../utils/error.ts"
5+ import fs from "node:fs/promises"
56import Path from "../utils/Path.ts"
67
78export default async function link ( pkg : Package | Installation ) {
@@ -44,6 +45,19 @@ export default async function link(pkg: Package | Installation) {
4445
4546 async function makeSymlink ( symname : string ) {
4647 try {
48+ const what_we_make = shelf . join ( symname )
49+ if ( what_we_make . isSymlink ( ) ) {
50+ try {
51+ // using this rather than rm due to bug in deno shims that
52+ // tries to call rmdir on the symlink because the symlink points to a dir
53+ await fs . unlink ( what_we_make . string )
54+ } catch ( err ) {
55+ // we were deleted by another thing linking simultaneously
56+ //FIXME our flock should surround the link step too
57+ if ( err . code != 'ENOENT' ) throw err
58+ }
59+ }
60+
4761 await Deno . symlink (
4862 installation . path . basename ( ) , // makes it relative
4963 shelf . join ( symname ) . rm ( ) . string ,
You can’t perform that action at this time.
0 commit comments