Skip to content

Commit

Permalink
on Windows, don't discard the symlink error (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
hegemonic committed Apr 13, 2014
1 parent 6480b96 commit 597a09d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions node/postinstall.js
Expand Up @@ -9,14 +9,14 @@ var jsdocPath = path.resolve( path.join(__dirname, '..') );
var symlinkSrc = path.join( jsdocPath, 'lib', 'jsdoc' );
var symlinkDest = path.join( jsdocPath, 'node_modules', 'jsdoc' );

function createJunction(err) {
function createJunction(symlinkErr) {
fs.symlink(symlinkSrc, symlinkDest, 'junction', function(junctionErr) {
if (junctionErr) {
console.error('Unable to create a symbolic link or junction from %s to %s.\n' +
'Symbolic link result: %s\nJunction result: %s\n' +
'Make sure you have write privileges in the target directory. ' +
'You may need to run the Windows shell as an administrator.',
symlinkSrc, symlinkDest, err, junctionErr);
symlinkSrc, symlinkDest, symlinkErr, junctionErr);
process.exit(1);
}
else {
Expand Down Expand Up @@ -48,20 +48,20 @@ function checkLink() {
});
}

fs.symlink(symlinkSrc, symlinkDest, 'dir', function(err) {
if (err) {
fs.symlink(symlinkSrc, symlinkDest, 'dir', function(symlinkErr) {
if (symlinkErr) {
// Does the symlink already exist? If so, does it point to the right place?
fs.lstat(symlinkDest, function(lstatErr, stats) {
if ( stats && stats.isSymbolicLink() ) {
checkLink();
}
// On Windows, try to create a junction instead
else if (process.platform.indexOf('win') === 0) {
createJunction();
createJunction(symlinkErr);
}
else {
console.error('Unable to create a symbolic link from %s to %s. %s\n', symlinkSrc,
symlinkDest, err);
symlinkDest, symlinkErr);
process.exit(1);
}
});
Expand Down

0 comments on commit 597a09d

Please sign in to comment.