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(cli): respect custom buildDir option for tasks sub command #2635

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

TMBL-DEV
Copy link

updated list & run to get a nitro instance and grab the buildDir from the nitro options and at the close the nitro instance.

πŸ”— Linked issue

#2634 Task cli forces .nitro as buildDir

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Changes

In run.ts & list.ts from the task command i used createNitro() to have a nitro instance so i could access the options.
i use the nitro.options.builDir to replace the hardcoded ".nitro" buildDir that is passed to the runTask function.
at the end of the command run function i also close the the nitro instance that i created.

Why

Now if your buildDir in the nitro.config.ts is not the default .nitro directory instead of getting an error it uses the correct buildDir and your command will run.
This will also make sure that the task cli works with nuxt, because nuxt uses the the buildDir .nuxt.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

updated list & run to get a nitro instance and grab the buildDir from the nitro options and at the close the nitro instance.
@pi0 pi0 changed the title fix(Tasks): replace hardcoded buildDir with nitro.options buildDir fix(cli): respect custom buildDir option Jul 26, 2024
@pi0 pi0 changed the title fix(cli): respect custom buildDir option fix(cli): respect custom buildDir option for tasks sub command Jul 26, 2024
@@ -16,13 +16,17 @@ export default defineCommand({
},
async run({ args }) {
const cwd = resolve((args.dir || args.cwd || ".") as string);
const tasks = await listTasks({ cwd, buildDir: ".nitro" });
const nitro = await createNitro({ rootDir: cwd });
Copy link
Member

Choose a reason for hiding this comment

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

I think you can use lighter loadConfig to load nitro config only

Copy link
Author

Choose a reason for hiding this comment

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

I'll take a look at it today

Copy link
Author

Choose a reason for hiding this comment

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

i used the loadOptions() because i couldn't find an example on the loadConfig function.
I hope that's okay.

@TMBL-DEV TMBL-DEV requested a review from pi0 July 31, 2024 11:01
@TMBL-DEV
Copy link
Author

@pi0 is this good?

@TMBL-DEV TMBL-DEV mentioned this pull request Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants