Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: resolve path before other logic #72

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"go.formatTool": "gofmt",
Expand Down
2 changes: 1 addition & 1 deletion src/core/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func Init(configPath, sh string, printOutput bool) string {
return errorString
}

aliae.Paths.Render()
aliae.Aliae.Render()
aliae.Envs.Render()
aliae.Paths.Render()
aliae.Scripts.Render()

script := shell.DotFile.String()
Expand Down
4 changes: 4 additions & 0 deletions src/shell/aliae.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (a Aliae) Render() {
continue
}

if first && DotFile.Len() > 0 {
DotFile.WriteString("\n\n")
}

if !first {
DotFile.WriteString("\n")
}
Expand Down
7 changes: 7 additions & 0 deletions src/shell/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
"os/exec"
"strings"
"text/template"

Expand Down Expand Up @@ -53,6 +54,7 @@ func funcMap() template.FuncMap {
"escapeString": escapeString,
"env": os.Getenv,
"match": match,
"hasCommand": hasCommand,
}
return template.FuncMap(funcMap)
}
Expand Down Expand Up @@ -91,3 +93,8 @@ func match(variable string, values ...string) bool {
}
return false
}

func hasCommand(command string) bool {
_, err := exec.LookPath(command)
return err == nil
}
17 changes: 9 additions & 8 deletions website/docs/setup/templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ configuration across multiple environments resulting in environment specific val

Out of the box you get the following functionality:

| Name | Type | Description | Example |
| -------- | ---------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `.Shell` | `string` | the current shell name | `{{ .Shell }}` |
| `.Home` | `string` | the user's `$HOME` folder | `{{ .Home }}/go/bin/aliae` |
| `.OS` | `string` | the current operating system (`windows`, `darwin`, `linux`) | `{{ .Home }}/go/bin/aliae{{ if eq .OS "windows" }}.exe{{ end }}` |
| `.Arch` | `string` | the `aliae` executable's compiled architecture | `{{ .Home }}/go/bin/aliae-{{ .Arch }}{{ if eq .OS "windows" }}.exe{{ end }}` |
| `env` | `function` | retrieve an environment variable value | `{{ env "POSH_THEME" }}` |
| `match` | `function` | match a shell name to one or multiple options | `{{ match .Shell "zsh" "bash" }}` |
| Name | Type | Description | Example |
| ------------ | --------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `.Shell` | `string` | the current shell name | `{{ .Shell }}` |
| `.Home` | `string` | the user's `$HOME` folder | `{{ .Home }}/go/bin/aliae` |
| `.OS` | `string` | the current operating system (`windows`, `darwin`, `linux`) | `{{ .Home }}/go/bin/aliae{{ if eq .OS "windows" }}.exe{{ end }}` |
| `.Arch` | `string` | the `aliae` executable's compiled architecture | `{{ .Home }}/go/bin/aliae-{{ .Arch }}{{ if eq .OS "windows" }}.exe{{ end }}` |
| `env` | `string` | retrieve an environment variable value | `{{ env "POSH_THEME" }}` |
| `match` | `boolean` | match a shell name to one or multiple options | `{{ match .Shell "zsh" "bash" }}` |
| `hasCommand` | `boolean` | check if an executable exists | `{{ hasCommand "oh-my-posh" }}` |

[go-text-template]: https://golang.org/pkg/text/template/
23,544 changes: 8,174 additions & 15,370 deletions website/package-lock.json

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
"private": true,
"scripts": {
"start": "cross-env NODE_ENV=development docusaurus start",
"serve": "docusaurus serve",
"build": "docusaurus build",
"themes": "node export_themes.js"
},
"dependencies": {
"@docusaurus/core": "^2.3.1",
"@docusaurus/preset-classic": "^2.3.1",
"@docusaurus/theme-search-algolia": "^2.3.1",
"@docusaurus/core": "^3.0.0",
"@docusaurus/preset-classic": "^3.0.0",
"@docusaurus/theme-search-algolia": "^3.0.0",
"@mdx-js/react": "^3.0.0",
"@iarna/toml": "^2.2.5",
"classnames": "^2.3.2",
"query-string": "7.1.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"yaml": "^2.2.2"
},
"resolutions": {
Expand All @@ -39,10 +41,10 @@
]
},
"engines": {
"npm": "8.9.0",
"node": "18.2.0"
"npm": "10.1.0",
"node": "20.9.0"
},
"volta": {
"node": "18.2.0"
"node": "20.9.0"
}
}
1 change: 1 addition & 0 deletions website/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
--ifm-color-primary-lighter: rgb(95, 157, 237);
--ifm-color-primary-lightest: rgb(8, 9, 10);
--ifm-code-font-size: 95%;
--ifm-pre-background: #232136;
}

.footer--dark {
Expand Down
Loading