elm-tooling
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -34,25 +34,13 @@ "use strict"; | ||
const linkPath = path.join(nodeModulesBinPath, tool.name); | ||
// Just like npm, just overwrite whatever links are already in | ||
// `node_modules/.bin/`. Most likely it’s either old links from for example | ||
// the `elm` npm package, or links from previous runs of this script. | ||
try { | ||
const target = fs.readlinkSync(linkPath); | ||
if (target === tool.absolutePath) { | ||
console.error(`${mixed_1.bold(`${tool.name} ${tool.version}`)} link already exists: ${mixed_1.dim(`${linkPath} -> ${target}`)}`); | ||
continue; | ||
} | ||
else { | ||
console.error(wrongSymlinkError(linkPath, target, tool.absolutePath)); | ||
return 1; | ||
} | ||
fs.unlinkSync(linkPath); | ||
} | ||
catch (errorAny) { | ||
const error = errorAny; | ||
switch (error.code) { | ||
case "ENOENT": | ||
// Does not exist yet – move on. | ||
break; | ||
case "EINVAL": | ||
console.error(`${linkPath} already exists, but is not a link to ${tool.absolutePath}\n${error.message}\nRemove it and try again.`); | ||
return 1; | ||
default: | ||
console.error(`Failed to create ${linkPath}:\n${error.message}`); | ||
return 1; | ||
if (error.code !== "ENOENT") { | ||
console.error(`Failed to remove old link for ${tool.name} at ${linkPath}: ${error.message}`); | ||
return 1; | ||
} | ||
@@ -65,3 +53,3 @@ } | ||
const error = errorAny; | ||
console.error(`Failed to create ${linkPath}: ${error.message}`); | ||
console.error(`Failed to create link for ${tool.name} at ${linkPath}: ${error.message}`); | ||
return 1; | ||
@@ -73,9 +61,1 @@ } | ||
} | ||
function wrongSymlinkError(linkPath, actual, expected) { | ||
return ` | ||
${linkPath} already exists, but links to something else. | ||
Expected: ${expected} | ||
Actual: ${actual} | ||
Remove it and try again. | ||
`.trim(); | ||
} |
{ | ||
"name": "elm-tooling", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Simon Lydell", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
{ | ||
"name": "elm-tooling", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Simon Lydell", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -57,3 +57,3 @@ # elm-tooling CLI | ||
- "elm-format": "0.8.3" | ||
+ "elm-tooling": "0.1.2" | ||
+ "elm-tooling": "0.1.3" | ||
}, | ||
@@ -60,0 +60,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43802
1064