Skip to content

Commit fd10e62

Browse files
committed
Fix install script breaking after first install
1 parent e7d7501 commit fd10e62

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

package-lock.json

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"devDependencies": {
1414
"find-steam-app": "^1.0.2",
15+
"fs-extra": "^8.1.0",
1516
"lua-types": "^2.6.2",
1617
"npm-run-all": "^4.1.5",
1718
"panorama-types": "^1.1.1",

scripts/install.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require("assert");
2-
const fs = require("fs");
2+
const fs = require("fs-extra");
33
const path = require("path");
44
const { getAddonName, getDotaPath } = require("./utils");
55

@@ -19,14 +19,18 @@ const { getAddonName, getDotaPath } = require("./utils");
1919

2020
const targetPath = path.join(dotaPath, directoryName, "dota_addons", getAddonName());
2121
if (fs.existsSync(targetPath)) {
22-
const isCorrect = fs.statSync(sourcePath).isSymbolicLink() && fs.realpathSync(sourcePath) === sourcePath;
23-
if (!isCorrect) {
24-
throw new Error(`'${targetPath}' already exists`);
22+
const isCorrect = fs.lstatSync(sourcePath).isSymbolicLink() && fs.realpathSync(sourcePath) === targetPath;
23+
if (isCorrect) {
24+
console.log(`Skipping '${sourcePath}' since it is already linked`);
25+
continue;
26+
} else {
27+
throw new Error(`'${targetPath}' is already linked to another directory`);
2528
}
2629
}
2730

28-
fs.renameSync(sourcePath, targetPath);
31+
fs.moveSync(sourcePath, targetPath);
2932
fs.symlinkSync(targetPath, sourcePath, "junction");
33+
console.log(`Linked ${sourcePath} <==> ${targetPath}`);
3034
}
3135
})().catch(error => {
3236
console.error(error);

0 commit comments

Comments
 (0)