Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc): ensure workspace directory is normalized correctly #16855

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/create-nx-workspace/src/create-empty-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ export async function createEmptyWorkspace<T extends CreateWorkspaceOptions>(
options.packageManager = packageManager;
}

const directory = getFileName(name);
options.name = getFileName(name);
const directory = options.name;

const args = unparse({
...options,
}).join(' ');

const pmc = getPackageManagerCommand(packageManager);

const command = `new ${directory} ${args}`;
const command = `new ${args}`;
Copy link
Member Author

@leosvelperez leosvelperez May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${directory} here was useless. The name arg takes precedence over the positional arg and overwrites it.

I'm normalizing the name option above, which is a known and required option, so we don't rely on the new generator rederiving it. We could also pass the directory option directly so it's more deterministic and we don't rely on some behavior in the new generator, but that option is not in the new generator schema for some reason. If someone can confirm whether it's intentional or just something we missed, I can add it and pass the option directly.


const workingDir = process.cwd().replace(/\\/g, '/');
let nxWorkspaceRoot = `"${workingDir}"`;
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/generators/new/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function normalizeOptions(options: Schema): NormalizedSchema {

normalized.name = names(options.name).fileName;
if (!options.directory) {
normalized.directory = options.name;
normalized.directory = normalized.name;
}

const parsed = parsePresetName(options.preset);
Expand Down