Skip to content

Commit 4000d7f

Browse files
committed
Fix --workspace-dir again
1 parent 2cab75b commit 4000d7f

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"pretty-bytes": "6.1.1",
2626
"prompts": "2.4.2",
2727
"semver": "7.6.0",
28-
"undici": "6.6.1",
28+
"undici": "6.6.2",
2929
"which": "4.0.0",
3030
"wrap-ansi": "9.0.0",
3131
"xpath": "0.0.34",

pnpm-lock.yaml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ export class CLI {
216216
if (Array.isArray(cmd?.options)) {
217217
const argv = this.argv;
218218
const cargv = cmd.opts();
219-
this.debugLogger.trace(`Copying ${cmd.options.length} options...`);
219+
this.debugLogger.trace(`Copying ${cmd.options.length} options... (${cmd.name()})`);
220220
for (const o of cmd.options) {
221221
let name = o.name();
222222
if (o.negate) {
223223
name = name.replace(/^no-/, '');
224224
}
225-
this.debugLogger.trace(` Setting ${name} = ${cargv[o.attributeName()]}`);
225+
this.debugLogger.trace(` Setting ${name} = ${cargv[o.attributeName()]} (prev: ${argv[name]})`);
226226
argv[name] = cargv[o.attributeName()];
227227
}
228228
}
@@ -550,6 +550,15 @@ export class CLI {
550550
const { conf, optionBranches } = cmd;
551551
const cmdName = cmd.name();
552552

553+
// this is a hack... `-d` now conflicts between `--workspace-dir` and
554+
// the now global `--project-dir` option causing `--project-dir` to
555+
// snipe `--workspace-dir`, so we treat them the same for the `create`
556+
// command
557+
if (cmdName === 'create' && !this.argv['workspace-dir'] && this.argv['project-dir']) {
558+
cmd.setOptionValue('workspaceDir', expand(this.argv['project-dir']));
559+
this.argv['project-dir'] = undefined;
560+
}
561+
553562
if (optionBranches?.length) {
554563
this.debugLogger.trace(`Processing missing option branches: ${optionBranches.join(', ')}`);
555564

@@ -774,7 +783,10 @@ export class CLI {
774783

775784
// if `--project-dir` was not set, default to the current working directory
776785
const cwd = expand(this.argv['project-dir'] || '.');
777-
this.argv['project-dir'] = cwd;
786+
if (cmdName !== 'create') {
787+
// create command doesn't have a --project-dir option
788+
this.argv['project-dir'] = cwd;
789+
}
778790

779791
// load hooks
780792
const hooks = ticonfig.paths?.hooks;
@@ -1302,14 +1314,6 @@ export class CLI {
13021314

13031315
this.debugLogger.trace('Checking for missing/invalid options:', orderedOptionNames);
13041316

1305-
// this is a hack... `-d` now conflicts between `--workspace-dir` and
1306-
// the now global `--project-dir` option causing `--project-dir` to
1307-
// snipe `--workspace-dir`, so we treat them the same for the `create`
1308-
// command
1309-
if (this.command.name() === 'create' && !this.argv['workspace-dir']) {
1310-
this.argv['workspace-dir'] = this.argv['project-dir'];
1311-
}
1312-
13131317
// this while loop is essentially a pump that processes missing/invalid
13141318
// options one at a time, recalculating them each iteration
13151319
// eslint-disable-next-line no-constant-condition

0 commit comments

Comments
 (0)