mirror of
https://github.com/thelounge/thelounge
synced 2024-11-21 19:43:07 +00:00
server: fix scoped package install
Installing a scoped npm package with thelounge install lead to an error, because the original split that was used to split the version from the package, split at the first @ from scoped packages.
This commit is contained in:
parent
a61bc14456
commit
0a4adc4592
1 changed files with 9 additions and 3 deletions
|
@ -47,9 +47,15 @@ program
|
||||||
.readFile(path.join(packageName.substring("file:".length), "package.json"), "utf-8")
|
.readFile(path.join(packageName.substring("file:".length), "package.json"), "utf-8")
|
||||||
.then((data) => JSON.parse(data) as typeof packageJson);
|
.then((data) => JSON.parse(data) as typeof packageJson);
|
||||||
} else {
|
} else {
|
||||||
const split = packageName.split("@");
|
// properly split scoped and non-scoped npm packages
|
||||||
packageName = split[0];
|
// into their name and version
|
||||||
const packageVersion = split[1] || "latest";
|
let packageVersion = "latest";
|
||||||
|
const atIndex = packageName.indexOf("@", 1);
|
||||||
|
|
||||||
|
if (atIndex !== -1) {
|
||||||
|
packageVersion = packageName.slice(atIndex + 1);
|
||||||
|
packageName = packageName.slice(0, atIndex);
|
||||||
|
}
|
||||||
|
|
||||||
readFile = packageJson.default(packageName, {
|
readFile = packageJson.default(packageName, {
|
||||||
fullMetadata: true,
|
fullMetadata: true,
|
||||||
|
|
Loading…
Reference in a new issue