Merge branch 'installExpandHome'

This commit is contained in:
Reto Brunner 2022-08-01 13:29:39 +02:00
commit 38bccd3635

View file

@ -37,8 +37,11 @@ program
if (packageName.startsWith("file:")) {
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(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);
} else {
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;