Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
add self update and add executable perms to binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpcdf committed Aug 7, 2022
1 parent 506eaa0 commit 955819a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config.nims
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

var mainfile = "jitter.nim"
var version = "0.2.5"
var version = "0.4.2-dev"
var nimble = getHomeDir() & ".nimble/pkgs"


Expand Down
26 changes: 18 additions & 8 deletions jitter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,23 @@ proc remove(input: string) =
pkg.remove()

success "Done"

proc update(input: string, make = true) =
let input =
if input.toLowerAscii() in ["this", "jtr", "jitter"]:
"sharpcdf/jitter"
else:
input
proc selfUpdate() =
ghDownload("sharpcdf/jitter", true)
var downloaded = false
var pkg: string
for p in getInstalledPkgs():
if p.owner == "sharpcdf" and p.repo == "jitter":
downloaded = true
pkg = p.pkgFormat()
break
if not downloaded:
fatal "Failed to update Jitter to latest version"
copyFile(nerveDir / pkg, getAppDir() / getAppFilename())
success "Successfully updated Jitter to the latest version!"
proc update(input: string, make = true) =
if input.toLowerAscii() in ["this", "jtr", "jitter"]:
selfUpdate()
return
if input.toLowerAscii() == "all":
for pkg in getInstalledPkgs():
pkg.remove()
Expand Down Expand Up @@ -187,7 +197,7 @@ const parser = newParser:
run:
opts.input.install(not opts.parentOpts.nomake)
command("update"): ## Create an update command
help("Updates the specified packages, or all packages if none are specified. user/repo[@tag]") ## Help message
help("Updates the specified package, Jitter itself, or all packages if specified. [user/repo[@tag]][all][this|jitter|jtr]") ## Help message
arg("input") ## Positional argument called input
run:
opts.input.update(not opts.parentOpts.nomake)
Expand Down
2 changes: 1 addition & 1 deletion jitter.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.3.0"
version = "0.4.0"
author = "sharpcdf"
description = "A git-based binary manager for linux."
license = "MIT"
Expand Down
4 changes: 3 additions & 1 deletion jitter/extract.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ proc extract*(pkg: Package, path, toDir: string, make = true) =

#Creates symlinks for executables and adds them to the bin
for file in walkDirRec(nerveDir / toDir):
if file.hasExecPerms() and not symlinkExists(binDir / file.splitFile().name):
if not symlinkExists(binDir / file.splitFile().name):
case file.splitFile().ext:
of "":
if not file.hasExecPerms():
file.setFilePermissions({fpUserExec, fpOthersExec})
file.createSymlink(binDir / file.splitFile().name)
success fmt"Created symlink {file.splitFile().name}"
of ".AppImage":
Expand Down

0 comments on commit 955819a

Please sign in to comment.