install: expand ~ for local paths
Make `thelounge install file:~/path/to/package` work rather than erroring out that the folder doesn't exists. Probably funny on Windows, but it doesn't hurt either
This commit is contained in:
parent
c8cd4057bc
commit
e221e708c1
@ -37,8 +37,11 @@ program
|
|||||||
|
|
||||||
if (packageName.startsWith("file:")) {
|
if (packageName.startsWith("file:")) {
|
||||||
isLocalFile = true;
|
isLocalFile = true;
|
||||||
|
// our yarn invocation sets $HOME to the cachedir, so we must expand ~ now
|
||||||
|
// else the path will be invalid when npm expands it.
|
||||||
|
packageName = expandTildeInLocalPath(packageName);
|
||||||
readFile = fspromises
|
readFile = fspromises
|
||||||
.readFile(path.join(packageName.substr("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("@");
|
const split = packageName.split("@");
|
||||||
@ -106,4 +109,9 @@ program
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function expandTildeInLocalPath(packageName: string): string {
|
||||||
|
const path = packageName.substring("file:".length);
|
||||||
|
return "file:" + Helper.expandHome(path);
|
||||||
|
}
|
||||||
|
|
||||||
export default program;
|
export default program;
|
||||||
|
Loading…
Reference in New Issue
Block a user