Skip to content

Commit

Permalink
Remove unnecessary global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Jan 18, 2025
1 parent d255783 commit 1956334
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 1 addition & 4 deletions internal/legacy/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ var (
PHPVersion = "0.0.0"
)

var phpPath = fmt.Sprintf("php-%s", PHPVersion)
var pharPath = fmt.Sprintf("phar-%s", LegacyCLIVersion)

// copyFile from the given bytes to destination
func copyFile(destination string, fin []byte) error {
if _, err := os.Stat(destination); err != nil && !os.IsNotExist(err) {
Expand Down Expand Up @@ -226,7 +223,7 @@ func (c *CLIWrapper) PharPath() string {
return customPath
}

return path.Join(c.cacheDir(), pharPath)
return path.Join(c.cacheDir(), c.Config.Application.Executable+".phar")
}

// ConfigPath returns the path to the YAML config file that will be provided to the legacy CLI.
Expand Down
7 changes: 3 additions & 4 deletions internal/legacy/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestLegacyCLI(t *testing.T) {

cnf := &config.Config{}
cnf.Application.Name = "Test CLI"
cnf.Application.Executable = "platform-test"
cnf.Application.Slug = "test-cli"
cnf.Application.EnvPrefix = "TEST_CLI_"
cnf.Application.TempSubDir = "temp_sub_dir"
Expand Down Expand Up @@ -52,22 +53,20 @@ func TestLegacyCLI(t *testing.T) {
}
LegacyCLIVersion = "test_legacy_cli_version"
PHPVersion = "test_php_version"
pharPath = "platform-test.phar"
phpPath = "php-test"

err := wrapper.Exec(context.Background(), "help")
assert.NoError(t, err)
assert.Contains(t, stdout.String(), "Displays help for a command")

assert.Equal(
t,
filepath.Join(os.TempDir(), "test-cli-test_php_version-test_legacy_cli_version", pharPath),
filepath.Join(os.TempDir(), "test-cli-test_php_version-test_legacy_cli_version", "platform-test.phar"),
wrapper.PharPath(),
)

assert.Equal(
t,
filepath.Join(os.TempDir(), "test-cli-test_php_version-test_legacy_cli_version", phpPath),
filepath.Join(os.TempDir(), "test-cli-test_php_version-test_legacy_cli_version", "php"),
wrapper.PHPPath(),
)

Expand Down
2 changes: 1 addition & 1 deletion internal/legacy/php_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c *CLIWrapper) copyPHP() error {

// PHPPath returns the path that the PHP CLI will reside
func (c *CLIWrapper) PHPPath() string {
return path.Join(c.cacheDir(), phpPath)
return path.Join(c.cacheDir(), "php")
}

func (c *CLIWrapper) phpSettings() []string {
Expand Down

0 comments on commit 1956334

Please sign in to comment.