feat(cli): nextSteps handle falsy values - #1215
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/sv/c/da4aac5bb0758801cdc1c21d05d1ea7687850fc7Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: da4aac5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Yes?! I find them a bit more cryptic! I don't have a huge opinion on this. Maybe others wanna have a look? I'll have to see why svelte.dev is not happy for |
AdrianGonz97
left a comment
There was a problem hiding this comment.
Yea, I agree with @jycouet on this one. I don't think allowing falsy values and filtering them out is a great improvement on clarity.
| }, | ||
|
|
||
| nextSteps: ({ options, packageManager, cwd, dependencyVersion }) => { | ||
| const pm = (command: Parameters<typeof resolveCommandArray>[1], args: string[]) => |
There was a problem hiding this comment.
this helper is a nice addition though. we could keep that
There was a problem hiding this comment.
Online here ? Or even higher ? To be used in other spots ? 👀
I don't have a strong opinion on this, but nextSteps: ({ isKit, packageManager }) =>
[
isKit && `Run ${color.command(resolveCommandArray(packageManager, "run", ["dev"]))} and consult ${color.website("http://localhost:5173/demo/markdown")} to see the result`,
`Read the documentation at ${color.website("https://github.com/ota-meshi/vite-plugin-svelte-md")}`,
],is a bit nicer than nextSteps: ({ isKit, packageManager }) =>
[
`Run ${color.command(resolveCommandArray(packageManager, "run", ["dev"]))} and consult ${color.website("http://localhost:5173/demo/markdown")} to see the result`,
`Read the documentation at ${color.website("https://github.com/ota-meshi/vite-plugin-svelte-md")}`,
].slice(isKit ? 0 : 1), |
|
I mean, if people really want it, nothing stops them from just filtering out the falsy values themselves: nextSteps: ({ isKit, packageManager }) =>
[
isKit && "...stuff 1",
isKit && "...more stuff 2",
isKit && packageManager === "pnpm" && "...even more stuff 3",
"...always added stuff 4",
].filter(Boolean), |
|
@AdrianGonz97 typescript does not resolve that correctly. microsoft/TypeScript#16655 You'd need to do this nextSteps: ({ isKit, packageManager }) => {
const notNullable = (x:any):x is NonNullable<typeof x> => Boolean(x)
return [
isKit && "...stuff 1",
isKit && "...more stuff 2",
isKit && packageManager === "pnpm" && "...even more stuff 3",
"...always added stuff 4",
].filter(notNullable)
} |
|
right, a bit more verbose to satisfy typescript then: nextSteps: ({ isKit, packageManager }) => [
isKit && "...stuff 1",
isKit && "...more stuff 2",
isKit && packageManager === "pnpm" && "...even more stuff 3",
"...always added stuff 4",
].filter((line): line is string => !!line),annoying but still doable |
Closes #
Description
Checklist