Skip to content
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 .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
go-version: 1.24.x

- name: Check out code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: "Set up Go"
uses: actions/setup-go@v4
with:
go-version: 1.21.x
go-version: 1.24.x
check-latest: true
cache: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
go-version: 1.24.x

- name: release test
uses: goreleaser/goreleaser-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
go-version: 1.24.x

- name: Check out code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.6-alpine AS builder
FROM golang:1.24.2-alpine AS builder
RUN apk add --no-cache git
RUN go install -v github.com/projectdiscovery/pdtm/cmd/pdtm@latest

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
## Installation


**`pdtm`** requires **go1.19** to install successfully. Run the following command to install the latest version:
**`pdtm`** requires **go1.24.2** to install successfully. Run the following command to install the latest version:

1. Install using go install -

Expand Down
2 changes: 1 addition & 1 deletion internal/runner/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
updateutils "github.com/projectdiscovery/utils/update"
)

const version = "v0.0.9"
const version = "v0.0.10"

var banner = `
____
Expand Down
48 changes: 43 additions & 5 deletions pkg/path/unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ var confList = []*Config{
shellName: "zsh",
rcFile: ".zshrc",
},
{
shellName: "fish",
rcFile: ".config/fish/config.fish",
},
}

func (c *Config) GetRCFilePath() (string, error) {
Expand All @@ -32,6 +36,17 @@ func (c *Config) GetRCFilePath() (string, error) {
return "", err
}
rcFilePath := filepath.Join(home, c.rcFile)

// For fish, ensure the directory exists
if c.shellName == "fish" {
configDir := filepath.Dir(rcFilePath)
if !fileutil.FolderExists(configDir) {
if err := os.MkdirAll(configDir, os.ModePerm); err != nil {
return "", fmt.Errorf("failed to create fish config directory %v got %v", configDir, err)
}
}
}

if fileutil.FileExists(rcFilePath) {
return rcFilePath, nil
}
Expand Down Expand Up @@ -79,7 +94,13 @@ func add(path string) (bool, error) {
return false, errorutil.NewWithErr(err).Msgf("add %s to $PATH env", path)
}

script := fmt.Sprintf("export PATH=$PATH:%s\n\n", path)
var script string
if conf.shellName == "fish" {
script = fmt.Sprintf("fish_add_path %s\n\n", path)
} else {
script = fmt.Sprintf("export PATH=$PATH:%s\n\n", path)
}

return exportToConfig(conf, path, script)
}

Expand All @@ -93,8 +114,15 @@ func remove(path string) (bool, error) {
if err != nil {
return false, errorutil.NewWithErr(err).Msgf("remove %s from $PATH env", path)
}
pathVars = sliceutil.PruneEqual(pathVars, path)
script := fmt.Sprintf("export PATH=%s\n\n", strings.Join(pathVars, ":"))

var script string
if conf.shellName == "fish" {
script = fmt.Sprintf("set --erase fish_user_paths[contains $fish_user_paths %s]\n\n", path)
} else {
pathVars = sliceutil.PruneEqual(pathVars, path)
script = fmt.Sprintf("export PATH=%s\n\n", strings.Join(pathVars, ":"))
}

return exportToConfig(conf, path, script)
}

Expand All @@ -115,21 +143,31 @@ func exportToConfig(config *Config, path, script string) (bool, error) {
lines := strings.Split(strings.TrimSpace(string(b)), "\n")
for _, line := range lines {
if strings.EqualFold(line, strings.TrimSpace(script)) {
gologger.Info().Msgf("Run `source ~/%s` to add %s to $PATH ", config.rcFile, path)
if config.shellName == "fish" {
gologger.Info().Msgf("Run `source %s` to add %s to $PATH ", rcFilePath, path)
} else {
gologger.Info().Msgf("Run `source ~/%s` to add %s to $PATH ", config.rcFile, path)
}
return true, nil
}
}
f, err := os.OpenFile(rcFilePath, os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return false, err
}

script = fmt.Sprintf("\n\n# Generated for pdtm. Do not edit.\n%s", script)
if _, err := f.Write([]byte(script)); err != nil {
return false, err
}
if err := f.Close(); err != nil {
return false, err
}
gologger.Info().Label("WRN").Msgf("Run `source ~/%s` to add $PATH (%s)", config.rcFile, path)

if config.shellName == "fish" {
gologger.Info().Label("WRN").Msgf("Run `source %s` to add $PATH (%s)", rcFilePath, path)
} else {
gologger.Info().Label("WRN").Msgf("Run `source ~/%s` to add $PATH (%s)", config.rcFile, path)
}
return true, nil
}
Loading