Skip to content

Commit

Permalink
denodir
Browse files Browse the repository at this point in the history
  • Loading branch information
txthinking committed Jan 28, 2022
1 parent 65fed15 commit 5b9d53e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
func main() {
app := cli.NewApp()
app.Name = "nami"
app.Version = "20211227"
app.Usage = "A decentralized binary package manager"
app.Version = "20220128"
app.Usage = "The easy way to download command from anywhere"
app.Authors = []*cli.Author{
{
Name: "Cloud",
Expand Down
6 changes: 5 additions & 1 deletion nami.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

type Nami struct {
DenoDir string
CacheDir string
BinDir string
DB *bbolt.DB
Expand Down Expand Up @@ -79,6 +80,7 @@ func NewNami() (*Nami, error) {
}
return &Nami{
CacheDir: filepath.Join(s, ".nami", "cache"),
DenoDir: filepath.Join(s, ".nami", "deno"),
BinDir: bin,
DB: db,
}, nil
Expand Down Expand Up @@ -106,12 +108,14 @@ func (n *Nami) Install(name string) (func(), error) {
if s == "" {
s = "https://raw.githubusercontent.com/txthinking/nami/master/package/"
}
fmt.Println("Run", s+name+".js")
deno := filepath.Join(n.BinDir, "deno")
if runtime.GOOS == "windows" {
deno = filepath.Join(n.BinDir, "deno.exe")
}
cmd := exec.Command(deno, "run", "-r", "-A", s+name+".js")
cmd.Env = append(os.Environ(),
"DENO_DIR="+n.DenoDir,
)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nami.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var nami = (name) => {
return {
version: async (version)=>{
await Deno.writeFile(`${Deno.env.get("HOME")}/.nami/cache/version`, new TextEncoder().encode(version));
console.log(green(`Found version: ${version}`))
console.log(green(`version: ${version}`))
},
open_sourced_on: (homepage)=>{
console.log(green(`${name} has been open sourced on ${homepage}`))
Expand Down

0 comments on commit 5b9d53e

Please sign in to comment.