Skip to content

Commit 41294c2

Browse files
authored
Support Project Directory having spaces (#1920)
## Summary In aid of #1914 Added some basic support for spaces. I think this requires more extensive testing around: 1. plugins 2. flake packages I should try to have the examples tests run in cicd with a space in their path. ## How was it tested? ``` mkdir -p `/Users/<omitted>/code/jetpack/devbox-projects/path with space` devbox init devbox shell devbox add hello devbox add cowsay ``` could run: ``` cowsay hello ``` set `export FISH=$(which fish)` and repeat the above steps
1 parent 3167fa1 commit 41294c2

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

internal/devbox/shellrc.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ working_dir="$(pwd)"
5656
cd "{{ .ProjectDir }}" || exit
5757

5858
# Source the hooks file, which contains the project's init hooks and plugin hooks.
59-
. {{ .HooksFilePath }}
59+
. "{{ .HooksFilePath }}"
6060

6161
cd "$working_dir" || exit
6262

internal/devbox/shellrc_fish.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ set workingDir (pwd)
5959
cd "{{ .ProjectDir }}" || exit
6060

6161
# Source the hooks file, which contains the project's init hooks and plugin hooks.
62-
source {{ .HooksFilePath }}
62+
source "{{ .HooksFilePath }}"
6363

6464
cd "$workingDir" || exit
6565

internal/devbox/testdata/shellrc/basic/shellrc.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ working_dir="$(pwd)"
2121
cd "/path/to/projectDir" || exit
2222

2323
# Source the hooks file, which contains the project's init hooks and plugin hooks.
24-
. /path/to/projectDir/.devbox/gen/scripts/.hooks.sh
24+
. "/path/to/projectDir/.devbox/gen/scripts/.hooks.sh"
2525

2626
cd "$working_dir" || exit
2727

internal/devbox/testdata/shellrc/noshellrc/shellrc.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ working_dir="$(pwd)"
1515
cd "/path/to/projectDir" || exit
1616

1717
# Source the hooks file, which contains the project's init hooks and plugin hooks.
18-
. /path/to/projectDir/.devbox/gen/scripts/.hooks.sh
18+
. "/path/to/projectDir/.devbox/gen/scripts/.hooks.sh"
1919

2020
cd "$working_dir" || exit
2121

internal/nix/nix.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.jetpack.io/devbox/internal/boxcli/featureflag"
2020
"go.jetpack.io/devbox/internal/boxcli/usererr"
2121
"go.jetpack.io/devbox/internal/redact"
22+
"go.jetpack.io/devbox/nix/flake"
2223

2324
"go.jetpack.io/devbox/internal/debug"
2425
)
@@ -69,15 +70,19 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
6970
return nil, errors.WithStack(err)
7071
}
7172

73+
flakeRef, err := flake.ParseRef("path:" + flakeDirResolved)
74+
if err != nil {
75+
return nil, err
76+
}
77+
7278
if len(data) == 0 {
7379
cmd := exec.CommandContext(
7480
ctx,
75-
"nix", "print-dev-env",
76-
"path:"+flakeDirResolved,
81+
"nix", "print-dev-env", flakeRef.String(),
7782
)
7883
cmd.Args = append(cmd.Args, ExperimentalFlags()...)
7984
cmd.Args = append(cmd.Args, "--json")
80-
debug.Log("Running print-dev-env cmd: %s\n", cmd)
85+
debug.Log("Running print-dev-env cmd: %s\n\n\n", cmd)
8186
data, err = cmd.Output()
8287
if insecure, insecureErr := IsExitErrorInsecurePackage(err, "" /*pkgName*/, "" /*installable*/); insecure {
8388
return nil, insecureErr

internal/shellgen/tmpl/init-hook-wrapper.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Code here should be fish and POSIX compatible. That's why we use export to
55
remove the value
66
*/ -}}
77
export {{ .InitHookHash }}=true
8-
. {{ .RawHooksFile }}
8+
. "{{ .RawHooksFile }}"
99
export {{ .InitHookHash }}=""

internal/shellgen/tmpl/script-wrapper.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
if [ -z "${{ .InitHookHash }}" ]; then
1111
{{/* init hooks will export InitHookHash ensuring no recursive sourcing*/ -}}
12-
. {{ .InitHookPath }}
12+
. "{{ .InitHookPath }}"
1313
fi
1414

1515
{{ .Body }}

0 commit comments

Comments
 (0)