Skip to content

Commit 2745d51

Browse files
committed
Default auto-mount path within runCLI so we can test the default
1 parent b2552a9 commit 2745d51

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/playground/cli/src/mounts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ const ACTIVATE_FIRST_THEME_STEP = {
110110
/**
111111
* Auto-mounts resolution logic:
112112
*/
113-
export function expandAutoMounts(path: string, args: RunCLIArgs): RunCLIArgs {
113+
export function expandAutoMounts(args: RunCLIArgs): RunCLIArgs {
114+
const path = args.autoMount!;
115+
114116
const mount = [...(args.mount || [])];
115117
const mountBeforeInstall = [...(args['mount-before-install'] || [])];
116118

packages/playground/cli/src/run-cli.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,6 @@ export async function parseOptionsAndRunCLI() {
157157
// TODO: Update docs
158158
describe: `Automatically mount the current working directory. You can mount a WordPress directory, a plugin directory, a theme directory, a wp-content directory, or any directory containing PHP and HTML files.`,
159159
type: 'string',
160-
coerce(arg) {
161-
if (arg === 'false') {
162-
return '';
163-
}
164-
if (arg === '' || arg === 'true') {
165-
return process.cwd();
166-
}
167-
return arg;
168-
},
169160
})
170161
.option('follow-symlinks', {
171162
describe:
@@ -375,8 +366,14 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
375366
* Expand auto-mounts to include the necessary mounts and steps
376367
* when running in auto-mount mode.
377368
*/
378-
if (args.autoMount) {
379-
args = expandAutoMounts(args.autoMount, args);
369+
if (args.autoMount !== undefined) {
370+
if (args.autoMount === '') {
371+
// No auto-mount path was provided, so use the current working directory.
372+
// Note: We default here instead of in the yargs declaration
373+
// because it allows us to test the default as part of the runCLI unit tests.
374+
args = { ...args, autoMount: process.cwd() };
375+
}
376+
args = expandAutoMounts(args);
380377
}
381378

382379
if (args.quiet) {

0 commit comments

Comments
 (0)