Skip to content

Commit

Permalink
update tran, trying fixing home path for windows #42
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Aug 2, 2022
1 parent 558d8c1 commit 73939f9
Show file tree
Hide file tree
Showing 25 changed files with 25 additions and 20 deletions.
Empty file modified .gitattributes
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tran sync start

### Tran Config file

> tran config file is located at `~/.config/tran/tran.yml` | `$HOME/tran.yml`
> tran config file is located at `~/.tran/tran.yml`
```yml
config:
Expand Down
Empty file modified app/checker/checker.go
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion app/config/config.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
homeDir, _ = dfs.GetHomeDirectory()
tranConfigPath = filepath.Join(homeDir, ".config", "tran", "tran.yml")
tranConfigPath = filepath.Join(homeDir, ".tran", "tran.yml")
tranConfig, err = ioutil.ReadFile(tranConfigPath)
)

Expand Down
6 changes: 3 additions & 3 deletions app/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
Short: "Start sync your tran config.",
Run: func(cmd *cobra.Command, args []string) {
if username != ":username" {
exCmd := "echo '# My tran config - " + username + "\n\n## Clone\n\n```\ntran sync clone\n```\n\n**for more about sync command, run `tran sync -h`**' >> $HOME/.config/tran/README.md"
exCmd := "echo '# My tran config - " + username + "\n\n## Clone\n\n```\ntran sync clone\n```\n\n**for more about sync command, run `tran sync -h`**' >> $HOME/.tran/README.md"

gosh.Run(exCmd)
gosh.RunMulti(constants.Start_ml(), constants.Start_w())
Expand Down Expand Up @@ -134,7 +134,7 @@ func PushSync() {
if runtime.GOOS == "windows" {
err, out, errout := gosh.PowershellOutput(
`
$directoyPath = "~/.config/tran/.git"
$directoyPath = "~/.tran/.git"
if (Test-Path -path $directoyPath) {
Write-Host "Reading from .tran folder..."
Expand All @@ -158,7 +158,7 @@ func PushSync() {
} else {
err, out, errout := gosh.ShellOutput(
`
if [ -d ~/.config/tran/.git ]; then
if [ -d ~/.tran/.git ]; then
echo "📖 Reading from .tran folder..."
fi
`)
Expand Down
Empty file modified cmd/factory/default.go
100755 → 100644
Empty file.
Empty file modified cmd/tran/help-topic.go
100755 → 100644
Empty file.
Empty file modified cmd/tran/help.go
100755 → 100644
Empty file.
Empty file modified cmd/tran/root.go
100755 → 100644
Empty file.
24 changes: 12 additions & 12 deletions constants/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package constants

func Fetch_w() string {
return `
Remove-Item $HOME\.config\tran -Recurse -Force
Remove-Item $HOME\.tran -Recurse -Force
tran sync fetchx
Write-Host "Fetched Successfully"
`
}

func Fetch_ml() string {
return `
cd $HOME/.config/tran
cd $HOME/.tran
git pull
echo "Fetched Successfully ✅"
`
Expand All @@ -19,7 +19,7 @@ func Fetch_ml() string {
func Start_w() string {
return `
$username = tran auth get-username
cd $HOME\.config\tran
cd $HOME\.tran
git init
tran gh-repo create .tran -d "My tran config - $username" --private -y
git add .
Expand All @@ -34,7 +34,7 @@ func Start_w() string {
func Start_ml() string {
return `
username=$(tran auth get-username)
cd ~/.config/tran
cd ~/.tran
git init
tran gh-repo create .tran -d "My tran config - $username" --private -y
git add .
Expand All @@ -48,7 +48,7 @@ func Start_ml() string {
func Push_w() string {
return `
$lastDir = pwd
cd $HOME\.config\tran
cd $HOME\.tran
if (Test-Path -path .git) {
git add .
git commit -m "new change"
Expand All @@ -61,7 +61,7 @@ func Push_w() string {

func Push_ml() string {
return `
cd ~/.config/tran
cd ~/.tran
git add .
git commit -m "new tran config"
git push
Expand All @@ -71,7 +71,7 @@ func Push_ml() string {
func Pull_w() string {
return `
$lastDir = pwd
cd $HOME\.config\tran
cd $HOME\.tran
git pull
Expand All @@ -81,14 +81,14 @@ func Pull_w() string {

func Pull_ml() string {
return `
cd ~/.config/tran
cd ~/.tran
git pull
`
}

func Clone_w() string {
return `
$TRANDIR = $HOME\.config\tran
$TRANDIR = $HOME\.tran
if (Test-Path -path $TRANDIR) {
Remove-Item $TRANDIR -Recurse -Force
Expand All @@ -100,7 +100,7 @@ func Clone_w() string {

func Clone_ml() string {
return `
TRANDIR=~/.config/tran
TRANDIR=~/.tran
if [ -d $TRANDIR ]; then
rm -rf $TRANDIR
Expand All @@ -112,12 +112,12 @@ func Clone_ml() string {

func Clone_check_w() string {
return `
if (Test-Path -path $HOME\.config\tran) {
if (Test-Path -path $HOME\.tran) {
Write-Host "tran repo cloned successfully"
}
`
}

func Clone_check_ml() string {
return `if [ -d $HOME/.config/tran ]; then echo "tran repo cloned successfully ✅"; fi`
return `if [ -d $HOME/.tran ]; then echo "tran repo cloned successfully ✅"; fi`
}
Empty file modified core/tranx/id.go
100755 → 100644
Empty file.
11 changes: 8 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func defualtEditor() string {
}

// LoadConfig loads a users config and creates the config if it does not exist
// located at `~/.config/tran.yml`
// located at `~/.tran/tran.yml`
func LoadConfig(startDir *pflag.Flag) {
var err error

Expand All @@ -44,12 +44,17 @@ func LoadConfig(startDir *pflag.Flag) {
log.Fatal(err)
}

err = dfs.CreateDirectory(filepath.Join(homeDir, ".config", "tran"))
err = dfs.CreateDirectory(filepath.Join(homeDir, ".tran"))
if err != nil {
log.Fatal(err)
}

viper.AddConfigPath("$HOME/.config/tran")
viper.AddConfigPath("$HOME/.tran")

if runtime.GOOS == "windows" {
viper.AddConfigPath(`$USERPROFILE\\.tran`)
}

viper.SetConfigName("tran")
viper.SetConfigType("yml")

Expand Down
Empty file modified internal/tui/receive.go
100755 → 100644
Empty file.
Empty file modified internal/tui/send.go
100755 → 100644
Empty file.
Empty file modified ios/color.go
100755 → 100644
Empty file.
Empty file modified ios/console.go
100755 → 100644
Empty file.
Empty file modified ios/console_windows.go
100755 → 100644
Empty file.
Empty file modified ios/iostreams.go
100755 → 100644
Empty file.
Empty file modified ios/tty_size.go
100755 → 100644
Empty file.
Empty file modified ios/tty_size_windows.go
100755 → 100644
Empty file.
Empty file modified models/model.go
100755 → 100644
Empty file.
Empty file modified scripts/bfs.ps1
100755 → 100644
Empty file.
Empty file modified scripts/tag.sh
100755 → 100644
Empty file.
Empty file modified tools/errors.go
100755 → 100644
Empty file.
Empty file modified tools/text.go
100755 → 100644
Empty file.

0 comments on commit 73939f9

Please sign in to comment.