Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

fix: symlink on win32 platform without admin rights #162

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ module.exports = cls => class Reifier extends cls {
const dir = dirname(node.path)
const target = node.realpath
const rel = relative(dir, target)
return symlink(rel, node.path, 'dir')
return symlink(rel, node.path, this.linktype())
}

linktype (platform = process.platform) {
return platform === 'win32' ? 'junction' : 'dir'
}

[_warnDeprecated] (node) {
Expand Down
12 changes: 12 additions & 0 deletions test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,18 @@ t.test('add multiple pkgs in a specific order', async t => {
)
})

t.test('link type for win32', async t => {
t.strictEqual(newArb({}).linktype('win32'), 'junction')
})

t.test('link type for darwin', async t => {
t.strictEqual(newArb({}).linktype('darwin'), 'dir')
})

t.test('link type for linux', async t => {
t.strictEqual(newArb({}).linktype('linux'), 'dir')
})

t.test('save complete lockfile on update-all', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
Expand Down