Skip to content

Commit 6527e9d

Browse files
authored
[cleanup] nix/shell: rename configDir to projectDir (#447)
## Summary Doing the rename for `nix/shell.go` code. ## How was it tested? After this PR, the remaining references are to (1) pkgConfigDir which is unrelated (2) DevboxConfigDir in pkgconfig code, which I'm addressing in its own PR. ``` ❯ git grep -in configDir | grep -v cloud internal/impl/devbox.go:244: nix.WithPKGConfigDir(filepath.Join(d.projectDir, plugin.VirtenvBinPath)), internal/impl/devbox.go:323: nix.WithPKGConfigDir(filepath.Join(d.projectDir, plugin.VirtenvBinPath)), internal/nix/shell.go:42: pkgConfigDir string internal/nix/shell.go:141:func WithPKGConfigDir(pkgConfigDir string) ShellOption { internal/nix/shell.go:143: s.pkgConfigDir = pkgConfigDir internal/nix/shell.go:371: if s.pkgConfigDir != "" { internal/nix/shell.go:372: pathPrepend = s.pkgConfigDir + ":" + pathPrepend internal/plugin/pkgcfg.go:80: "DevboxConfigDir": rootDir, internal/plugin/pkgcfg.go:154: "DevboxConfigDir": rootDir, plugins/apacheHttpd.json:6: "HTTPD_DEVBOX_CONFIG_DIR": "{{ .DevboxConfigDir }}", ```
1 parent 1bd8917 commit 6527e9d

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

internal/impl/devbox.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (d *Devbox) Shell() error {
250250
nix.WithPluginInitHook(strings.Join(pluginHooks, "\n")),
251251
nix.WithProfile(profileDir),
252252
nix.WithHistoryFile(filepath.Join(d.projectDir, shellHistoryFile)),
253-
nix.WithConfigDir(d.projectDir),
253+
nix.WithProjectDir(d.projectDir),
254254
}
255255
// TODO: separate package suggestions from shell planners
256256
if featureflag.PKGConfig.Enabled() {
@@ -290,7 +290,7 @@ func (d *Devbox) RunScriptInShell(scriptName string) error {
290290
nix.WithProfile(profileDir),
291291
nix.WithHistoryFile(filepath.Join(d.projectDir, shellHistoryFile)),
292292
nix.WithUserScript(scriptName, script.String()),
293-
nix.WithConfigDir(d.projectDir),
293+
nix.WithProjectDir(d.projectDir),
294294
)
295295

296296
if err != nil {
@@ -329,7 +329,7 @@ func (d *Devbox) RunScript(scriptName string) error {
329329
nix.WithProfile(profileDir),
330330
nix.WithHistoryFile(filepath.Join(d.projectDir, shellHistoryFile)),
331331
nix.WithUserScript(scriptName, script.String()),
332-
nix.WithConfigDir(d.projectDir),
332+
nix.WithProjectDir(d.projectDir),
333333
}
334334

335335
if featureflag.PKGConfig.Enabled() {

internal/nix/shell.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
type Shell struct {
4040
name name
4141
binPath string
42-
configDir string // path to where devbox.json config resides
42+
projectDir string // path to where devbox.json config resides
4343
pkgConfigDir string
4444
env []string
4545
userShellrcPath string
@@ -145,9 +145,9 @@ func WithPKGConfigDir(pkgConfigDir string) ShellOption {
145145
}
146146
}
147147

148-
func WithConfigDir(configDir string) ShellOption {
148+
func WithProjectDir(projectDir string) ShellOption {
149149
return func(s *Shell) {
150-
s.configDir = configDir
150+
s.projectDir = projectDir
151151
}
152152
}
153153

@@ -385,7 +385,7 @@ func (s *Shell) writeDevboxShellrc() (path string, err error) {
385385
}
386386

387387
err = shellrcTmpl.Execute(shellrcf, struct {
388-
ConfigDir string
388+
ProjectDir string
389389
EnvToKeep map[string]string
390390
OriginalInit string
391391
OriginalInitPath string
@@ -396,7 +396,7 @@ func (s *Shell) writeDevboxShellrc() (path string, err error) {
396396
ProfileBinDir string
397397
HistoryFile string
398398
}{
399-
ConfigDir: s.configDir,
399+
ProjectDir: s.projectDir,
400400
EnvToKeep: envToKeepFlakes,
401401
OriginalInit: string(bytes.TrimSpace(userShellrc)),
402402
OriginalInitPath: filepath.Clean(s.userShellrcPath),

internal/nix/shell_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestWriteDevboxShellrc(t *testing.T) {
4949
for _, test := range tests {
5050
t.Run(test.name, func(t *testing.T) {
5151
s := &Shell{
52-
configDir: "path/to/configDir",
52+
projectDir: "path/to/projectDir",
5353
userShellrcPath: test.shellrcPath,
5454
UserInitHook: test.hook,
5555
pluginInitHook: `echo "Welcome to the devbox!"`,

internal/nix/shellrc.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export PS1="(devbox) $PS1"
5050

5151
# Switch to the directory where devbox.json config is
5252
workingDir=$(pwd)
53-
cd {{ .ConfigDir }}
53+
cd {{ .ProjectDir }}
5454

5555
{{ .UserHook }}
5656

@@ -76,7 +76,7 @@ cd $workingDir
7676

7777
function run_script {
7878
workingDir=$(pwd)
79-
cd {{ .ConfigDir }}
79+
cd {{ .ProjectDir }}
8080

8181
{{ .ScriptCommand }}
8282

internal/nix/testdata/shellrc/basic/shellrc.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export PS1="(devbox) $PS1"
5656

5757
# Switch to the directory where devbox.json config is
5858
workingDir=$(pwd)
59-
cd path/to/configDir
59+
cd path/to/projectDir
6060

6161
echo "Hello from a devbox shell hook!"
6262

internal/nix/testdata/shellrc/noshellrc/shellrc.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export PS1="(devbox) $PS1"
1414

1515
# Switch to the directory where devbox.json config is
1616
workingDir=$(pwd)
17-
cd path/to/configDir
17+
cd path/to/projectDir
1818

1919
echo "Hello from a devbox shell hook!"
2020

0 commit comments

Comments
 (0)