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

add NPM 5 support #17

Merged
merged 2 commits into from
Oct 19, 2017
Merged
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
11 changes: 3 additions & 8 deletions src/util/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -59,5 +54,5 @@ module.exports = {
whackageJsonDoesntExist,
isValidModule,
isOwnDependency,
isNotSymlinked
isSymlinked
};
6 changes: 5 additions & 1 deletion src/util/start-server.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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(packagePath);
}
syncAll(ROOT_PATH, key, packageLookup[key], exclude);
}
}
Expand Down