Skip to content

Commit

Permalink
MAINTENANCE
Browse files Browse the repository at this point in the history
* Improve symlink handling
  • Loading branch information
tonysamperi committed Jun 3, 2023
1 parent 55ffdc8 commit ab489ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions symlink.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require("fs");
const {join, toNamespacedPath} = require("path");
const {join} = require("path");
const pkg = require("./package.json");

(function createSymlink() {
Expand All @@ -9,7 +9,12 @@ const pkg = require("./package.json");
if (fs.existsSync(nodeModulesPath)) {
fs.unlinkSync(nodeModulesPath);
}
fs.symlink(join(__dirname, targetPath), nodeModulesPath, 'dir', (err) => {
if (!fs.existsSync(targetPath)) {
console.info("Target folder doesn't exist, stop before creating new symlink");
return;
}

fs.symlink(join(__dirname, targetPath), nodeModulesPath, "dir", (err) => {
if (err) {
console.log(err);
}
Expand Down

0 comments on commit ab489ef

Please sign in to comment.