From d4743acf20c7cbce24a7958e1a9ae699468d0ff8 Mon Sep 17 00:00:00 2001 From: yhahn Date: Wed, 11 Jan 2012 09:46:39 -0800 Subject: [PATCH] Loosen symlink monkeypatching to apply to all win32. --- index.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index 116790758..e540f2d71 100755 --- a/index.js +++ b/index.js @@ -14,20 +14,16 @@ if (process.platform === 'win32') { // HOME is undefined on windows process.env.HOME = process.env.HOMEPATH; - // test for symlink support and fallback - // to full copying of files if lacking - try { - fs.symlinkSync('/tmp/from.txt','/tmp/to.txt'); - } catch (err) { - if (err.code === 'ENOTSUP') { - fs.symlink = function(from,to,cb) { - try { - require('./lib/fsutil').cprSync(from,to); - return cb(); - } catch (err) { - return cb(err); - } - } + // don't attempt symlink support at all -- just copy. + // @TODO write a dotfile next to the copy with the link + // "metadata" so we can monkeypatch readlink as well. + var cprSync = require('./lib/fsutil').cprSync; + fs.symlink = function(from,to,cb) { + try { + cprSync(from, to); + return cb(); + } catch (err) { + return cb(err); } } }