-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
A command field in astro:config:setup returns build value while running check command #10876
Copy link
Copy link
Closed
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)feat: integration apirelated to the public integration APIs (scope)related to the public integration APIs (scope)
Description
Astro Info
Astro v4.7.0
Node v18.18.0
System Linux (x64)
Package Manager unknown
Output static
Adapter none
Integrations test
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Let's assume an Astro config like below:
export default defineConfig({
integrations: [
{
name: 'test',
hooks: {
'astro:config:setup': ({ command }) => {
console.log(command);
},
},
},
],
});While running astro check the console outputs build string. This can be confusing, especially when running the command in the default pipeline: astro check & astro build. In this case, the astro:config:setup hook is called twice with command === 'build', unexpectedly triggering certain code twice during the build.
Also, this behavior isn't documented: https://docs.astro.build/en/reference/integrations-reference/#command-option
It appears to be caused by a hardcoded 'build' value in the mentioned line:https://github.com/withastro/astro/blob/main/packages/astro/src/core/sync/index.ts#L62
const settings = await runHookConfigSetup({
settings: _settings,
logger: logger,
command: 'build', // <- here
});What's the expected result?
I suggest three possible solutions:
commandwhile runningastro checkhascheckvalueastro checkcommand is integrated withastro buildalways, soastro:config:setupcalls once only (I think it's the worst option)- Describe this behavior in documentation
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-yfhwgr?file=astro.config.mjs
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)feat: integration apirelated to the public integration APIs (scope)related to the public integration APIs (scope)