Skip to content

Instantly share code, notes, and snippets.

@marckassay
Created November 3, 2018 11:29
Show Gist options
  • Save marckassay/11c91a5f3759ddf9c2056e615e9610c8 to your computer and use it in GitHub Desktop.
Save marckassay/11c91a5f3759ddf9c2056e615e9610c8 to your computer and use it in GitHub Desktop.
Demonstrates when 'yarn unlinks', symlink in user home directory still exists. See issue here: https://github.com/yarnpkg/yarn/issues/6560
$PackageName = "yarn-example-no$(Get-Random -Maximum 1000)"
New-Item -Value @"
{
"name": "$PackageName",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true
}
"@ -Name package.json -Path $PackageName -Force | Out-Null
sl $PackageName
yarn link
sl ..
$PriorToUnlink = Get-ChildItem "~\AppData\Local\Yarn\Data\link\" -Directory | Where-Object {$_.Attributes -match [IO.FileAttributes]::ReparsePoint}
yarn unlink $PackageName
$PostToUnlink = Get-ChildItem "~\AppData\Local\Yarn\Data\link\" -Directory | Where-Object {$_.Attributes -match [IO.FileAttributes]::ReparsePoint}
Write-Host "Expecting '`$PriorToUnlink.Length' to not equal '`$PostToUnlink.Length'. Actual results are: '`$PriorToUnlink.Length' is $($PriorToUnlink.Length) and '`$PostToUnlink.Length' is $($PostToUnlink.Length)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment