From 77c9b7233ef6555ad23be3ef1756565e5b590274 Mon Sep 17 00:00:00 2001 From: JP Driver Date: Wed, 18 Oct 2017 15:28:58 +0100 Subject: [PATCH 1/2] dont bail when using symlinks --- src/util/assert.js | 11 +++-------- src/util/start-server.js | 6 +++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/util/assert.js b/src/util/assert.js index cbefef1..80d7b5b 100644 --- a/src/util/assert.js +++ b/src/util/assert.js @@ -43,14 +43,9 @@ function isOwnDependency(packageName) { } } -function isNotSymlinked(packageName) { +function isSymlinked(packageName) { const packagePath = path.resolve(process.cwd(), 'node_modules', packageName); - if (isSymlink.sync(packagePath)) { - exitWith( - `Package ${packageName} appears to be symlinked. ` + - 'Overwriting symlinks is not currently supported. Unlink package and try again.' - ); - } + return isSymlink.sync(packagePath) } module.exports = { @@ -59,5 +54,5 @@ module.exports = { whackageJsonDoesntExist, isValidModule, isOwnDependency, - isNotSymlinked + isSymlinked }; diff --git a/src/util/start-server.js b/src/util/start-server.js index b583c31..207cc87 100644 --- a/src/util/start-server.js +++ b/src/util/start-server.js @@ -1,4 +1,5 @@ const path = require('path'); +const fs = require('fs-extra'); const chokidar = require('chokidar'); const assert = require('./assert'); const syncAll = require('./sync-all'); @@ -32,7 +33,10 @@ module.exports = function startServer() { // initial sync for (const key in packageLookup) { if (packageLookup.hasOwnProperty(key)) { - assert.isNotSymlinked(packageLookup[key]); + if (assert.isSymlinked(packageLookup[key])) { + const packagePath = path.resolve(process.cwd(), 'node_modules', packageLookup[key]); + fs.removeSync(packageLookup[key]); + } syncAll(ROOT_PATH, key, packageLookup[key], exclude); } } From 76504ef9f7af53a705c619cac7ff232b1056b8e2 Mon Sep 17 00:00:00 2001 From: JP Driver Date: Thu, 19 Oct 2017 11:17:52 +0100 Subject: [PATCH 2/2] should be passing packagePath to removeSync --- src/util/start-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/start-server.js b/src/util/start-server.js index 207cc87..f6f224d 100644 --- a/src/util/start-server.js +++ b/src/util/start-server.js @@ -35,7 +35,7 @@ module.exports = function startServer() { if (packageLookup.hasOwnProperty(key)) { if (assert.isSymlinked(packageLookup[key])) { const packagePath = path.resolve(process.cwd(), 'node_modules', packageLookup[key]); - fs.removeSync(packageLookup[key]); + fs.removeSync(packagePath); } syncAll(ROOT_PATH, key, packageLookup[key], exclude); }