Skip to content

Commit

Permalink
Fix --workspace-dir again
Browse files Browse the repository at this point in the history
  • Loading branch information
cb1kenobi committed Feb 7, 2024
1 parent 2cab75b commit 4000d7f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"pretty-bytes": "6.1.1",
"prompts": "2.4.2",
"semver": "7.6.0",
"undici": "6.6.1",
"undici": "6.6.2",
"which": "4.0.0",
"wrap-ansi": "9.0.0",
"xpath": "0.0.34",
Expand Down
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ export class CLI {
if (Array.isArray(cmd?.options)) {
const argv = this.argv;
const cargv = cmd.opts();
this.debugLogger.trace(`Copying ${cmd.options.length} options...`);
this.debugLogger.trace(`Copying ${cmd.options.length} options... (${cmd.name()})`);
for (const o of cmd.options) {
let name = o.name();
if (o.negate) {
name = name.replace(/^no-/, '');
}
this.debugLogger.trace(` Setting ${name} = ${cargv[o.attributeName()]}`);
this.debugLogger.trace(` Setting ${name} = ${cargv[o.attributeName()]} (prev: ${argv[name]})`);
argv[name] = cargv[o.attributeName()];
}
}
Expand Down Expand Up @@ -550,6 +550,15 @@ export class CLI {
const { conf, optionBranches } = cmd;
const cmdName = cmd.name();

// this is a hack... `-d` now conflicts between `--workspace-dir` and
// the now global `--project-dir` option causing `--project-dir` to
// snipe `--workspace-dir`, so we treat them the same for the `create`
// command
if (cmdName === 'create' && !this.argv['workspace-dir'] && this.argv['project-dir']) {
cmd.setOptionValue('workspaceDir', expand(this.argv['project-dir']));
this.argv['project-dir'] = undefined;
}

if (optionBranches?.length) {
this.debugLogger.trace(`Processing missing option branches: ${optionBranches.join(', ')}`);

Expand Down Expand Up @@ -774,7 +783,10 @@ export class CLI {

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

// load hooks
const hooks = ticonfig.paths?.hooks;
Expand Down Expand Up @@ -1302,14 +1314,6 @@ export class CLI {

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

// this is a hack... `-d` now conflicts between `--workspace-dir` and
// the now global `--project-dir` option causing `--project-dir` to
// snipe `--workspace-dir`, so we treat them the same for the `create`
// command
if (this.command.name() === 'create' && !this.argv['workspace-dir']) {
this.argv['workspace-dir'] = this.argv['project-dir'];
}

// this while loop is essentially a pump that processes missing/invalid
// options one at a time, recalculating them each iteration
// eslint-disable-next-line no-constant-condition
Expand Down

0 comments on commit 4000d7f

Please sign in to comment.