-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: basic support for global install (WIP)
- Loading branch information
Showing
6 changed files
with
104 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,5 @@ | |
} | ||
}, | ||
"name": "gupm", | ||
"version": "1.2.0" | ||
"version": "1.2.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"./ui" | ||
"./utils" | ||
) | ||
|
||
func installBins(path string) { | ||
var GLOBAL = utils.Path(utils.HOMEDIR(".") + "/.gupm/global") | ||
bins := utils.RecursiveFileWalkDir(GLOBAL + "/.bin") | ||
|
||
for _, bin := range bins { | ||
name := filepath.Base(bin) | ||
if !utils.FileExists(path + "/" + name) { | ||
os.Symlink(bin, path+"/"+name) | ||
} | ||
} | ||
} | ||
|
||
func GlobalAdd(rls []string) { | ||
ui.Title("Installing global dependency...") | ||
var GLOBAL = utils.Path(utils.HOMEDIR(".") + "/.gupm/global") | ||
|
||
if !utils.FileExists(GLOBAL + utils.Path("/gupm.json")) { | ||
os.MkdirAll(GLOBAL, os.ModePerm) | ||
utils.WriteFile(GLOBAL+utils.Path("/gupm.json"), "{}") | ||
} | ||
|
||
ui.Log("Installing...") | ||
AddDependency(GLOBAL, rls) | ||
InstallProject(GLOBAL) | ||
|
||
ui.Log("Add binaries...") | ||
if utils.OSNAME() != "windows" { | ||
if utils.FileExists("/usr/local/bin/") { | ||
installBins("/usr/local/bin/") | ||
} else { | ||
installBins("/usr/bin/") | ||
} | ||
} else { | ||
ui.Error("Global Installation not supported on Windows yet. Please add .gupm/global/.bin to your PATH") | ||
} | ||
} | ||
|
||
func GlobalDelete(rls []string) { | ||
var GLOBAL = utils.Path(utils.HOMEDIR(".") + "/.gupm/global") | ||
|
||
if !utils.FileExists(GLOBAL + utils.Path("/gupm.json")) { | ||
os.MkdirAll(GLOBAL, os.ModePerm) | ||
utils.WriteFile(GLOBAL+utils.Path("/gupm.json"), "{}") | ||
} | ||
|
||
RemoveDependency(GLOBAL, rls) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters