Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Workspace prompt rejects existing folders entered with ~, quotes or escaped spaces

Aperta Adatta ai principianti
#9 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
cli

Direzione di ricerca

Inizia con validateWorkspace() e saveWorkspace() in lib/cli.js; al momento entrambi rimuovono gli spazi iniziali e finali dal valore del prompt e lo risolvono come percorso. Segui come viene usata nei test l’iniezione della piattaforma esistente, poi aggiungi test per la tilde, i percorsi tra virgolette, gli spazi con escape e i messaggi di errore. Il lavoro è completo quando gli input validi di cartelle esistenti funzionano in entrambi i prompt e la configurazione memorizza il percorso assoluto semplice.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Description

The README's Quick start says:

On the first launch, enter the folder that contains your projects, for example: ~/projects/

Entering ~/projects at that prompt is rejected, even when the folder exists:

That directory does not exist or is not accessible.

The prompt only trims the input and passes it to path.resolve(). Nothing expands ~, because the shell never sees text typed into a prompt, so ~/projects resolves to <current directory>/~/projects. For the same reason, two other common forms of an existing path are rejected:

  • quoted paths ("…" or '…'). Windows Explorer's Copy as path always adds double quotes, and many terminals quote a dragged folder whose path contains spaces;
  • escaped spaces (my\ projects), which some terminals produce when a folder is dragged in.

This applies to the first-run prompt and to Change workspace. dws --workspace ~/projects works because the shell expands the path before the CLI receives it.

Steps to reproduce
  1. Create two workspaces, one matching the README example and one with a space in its name:

    mkdir -p ~/projects/storefront ~/"my projects"/app
    echo '{"scripts":{"dev":"echo dev"}}' > ~/projects/storefront/package.json
    echo '{"scripts":{"hello":"echo hello"}}' > ~/"my projects"/app/package.json
    
  2. Start the published CLI with an empty configuration file, which triggers the first-run prompt:

    DEV_WORKSPACE_CONFIG=/tmp/dws-first-run.json \
      npx -p @modulane/[email protected] dws
    
  3. At Workspace path, enter each of these values, replacing /home/you with your home directory:

    ~/projects
    ~/my projects
    "/home/you/my projects"
    '/home/you/my projects'
    /home/you/my\ projects
    
Actual behaviour

Every value is rejected:

? Workspace path ~/projects
> That directory does not exist or is not accessible.

Only the bare absolute path (/home/you/my projects) is accepted. Choosing Change workspace from the project list and entering ~/projects gives the same error.

Expected behaviour

Each input resolves to the existing folder, and the configuration stores the plain absolute path.

When a path really doesn't exist, the error names the path that was checked, for example No directory at /current/dir/~/projects, so the cause is obvious.

Where
Suggested fix

Add a single helper that resolves the prompt input, used by both functions:

  1. Trim the input. If the path exists as typed, use it unchanged, so a folder whose real name contains quotes or backslashes keeps working.
  2. Otherwise, try a normalised form:
    • remove one pair of matching surrounding quotes;
    • expand a leading ~ (alone, or followed by /, or by \ on Windows) with os.homedir();
    • on non-Windows platforms only, turn \ into a space. On Windows, \ is the path separator.
  3. Use the error message above when neither form exists.

Each case can be unit-tested, including Windows-style input through the existing platform injection pattern.

This also helps the planned first-run experience in ROADMAP.md, which suggests ~/dev and ~/projects and keeps "Enter another path" as an option.

I'm happy to open a PR for this.

Environment
  • @modulane/dev-workspace-cli 0.5.0 from npm. lib/ is identical on main at dfccb6b.
  • Node.js 22.22.2, Linux x64. Windows and macOS were not tested; the code path is the same on every platform.
Lingua principale
JavaScript
Stelle
0
Fork
0
Merge medio
7m
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modulane/dev-workspace-cli

Tutte le issue di modulane/dev-workspace-cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.