Skip to content

Commit ebb26a6

Browse files
committed
Merge pull request #11 from vweevers/master
Absolute junctions for Windows XP
2 parents 1e0e295 + cec9059 commit ebb26a6

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ var mkdirp = require('mkdirp')
77
var rimraf = require('rimraf')
88
var assert = require('assert')
99
var map = require('map-limit')
10+
var os = require('os')
11+
12+
// Use junctions on Windows < Vista (6.0),
13+
// Vista and later support regular symlinks.
14+
if (os.platform()=='win32' && parseInt(os.release())<6) {
15+
var symlinkType = 'junction'
16+
} else {
17+
symlinkType = 'dir'
18+
}
1019

1120
module.exports = function linklocal(dirpath, _done) {
1221
function done(err, items) {
@@ -280,9 +289,16 @@ function linkLinks(links, done) {
280289
map(links, Infinity, function(link, next) {
281290
mkdirp(path.dirname(link.from), function(err) {
282291
if (err && err.code !== 'EEXISTS') return next(err)
292+
283293
var from = link.from
284-
var to = path.relative(path.dirname(link.from), link.to)
285-
fs.symlink(to, from, 'junction', function(err) {
294+
var to = link.to
295+
296+
// Junction points can't be relative
297+
if (symlinkType!=='junction') {
298+
to = path.relative(path.dirname(from), to)
299+
}
300+
301+
fs.symlink(to, from, symlinkType, function(err) {
286302
if (err) return next(new Error('Error linking ' +from+ ' to ' + to + ':\n' + err.message))
287303
next(null, link)
288304
})

0 commit comments

Comments
 (0)