mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 22:18:41 -09:00
Fix CLI installation on Windows (#2600)
* Protect against missing PATH user env var * Protect against different cases for PATH user env var name Fixes #2580
This commit is contained in:
parent
ac5c14adca
commit
5f64127f5b
1 changed files with 18 additions and 13 deletions
|
|
@ -60,21 +60,26 @@ exports.addBinToUserPath = () => {
|
||||||
// C:\Users\<user>\AppData\Local\hyper
|
// C:\Users\<user>\AppData\Local\hyper
|
||||||
const basePath = path.resolve(binPath, '../../..');
|
const basePath = path.resolve(binPath, '../../..');
|
||||||
|
|
||||||
const pathItem = items.find(item => item.name === 'Path');
|
const pathItem = items.find(item => item.name.toUpperCase() === 'PATH');
|
||||||
const pathParts = pathItem.value.split(';');
|
|
||||||
const existingPath = pathParts.find(pathPart => pathPart === binPath);
|
let newPathValue = binPath;
|
||||||
if (existingPath) {
|
const pathItemName = pathItem ? pathItem.name : 'PATH';
|
||||||
resolve();
|
if (pathItem) {
|
||||||
return;
|
const pathParts = pathItem.value.split(';');
|
||||||
|
const existingPath = pathParts.find(pathPart => pathPart === binPath);
|
||||||
|
if (existingPath) {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Because version is in path we need to remove old path if present and add current path
|
||||||
|
newPathValue = pathParts
|
||||||
|
.filter(pathPart => !pathPart.startsWith(basePath))
|
||||||
|
.concat([binPath])
|
||||||
|
.join(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because version is in path we need to remove old path if present and add current path
|
envKey.set(pathItemName, Registry.REG_SZ, newPathValue, error => {
|
||||||
const newPathValue = pathParts
|
|
||||||
.filter(pathPart => !pathPart.startsWith(basePath))
|
|
||||||
.concat([binPath])
|
|
||||||
.join(';');
|
|
||||||
|
|
||||||
envKey.set(pathItem.name, Registry.REG_SZ, newPathValue, error => {
|
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue