mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix astro add
generated import identifier (#12363)
This commit is contained in:
parent
493fe43cd3
commit
222f71894c
2 changed files with 11 additions and 1 deletions
5
.changeset/five-maps-bake.md
Normal file
5
.changeset/five-maps-bake.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes code generated by `astro add` command when adding a version of an integration other than the default `latest`.
|
|
@ -390,13 +390,16 @@ function isAdapter(
|
|||
// Some examples:
|
||||
// - @astrojs/image => image
|
||||
// - @astrojs/markdown-component => markdownComponent
|
||||
// - @astrojs/image@beta => image
|
||||
// - astro-cast => cast
|
||||
// - astro-cast@next => cast
|
||||
// - markdown-astro => markdown
|
||||
// - some-package => somePackage
|
||||
// - example.com => exampleCom
|
||||
// - under_score => underScore
|
||||
// - 123numeric => numeric
|
||||
// - @npm/thingy => npmThingy
|
||||
// - @npm/thingy@1.2.3 => npmThingy
|
||||
// - @jane/foo.js => janeFoo
|
||||
// - @tokencss/astro => tokencss
|
||||
const toIdent = (name: string) => {
|
||||
|
@ -409,7 +412,9 @@ const toIdent = (name: string) => {
|
|||
// convert to camel case
|
||||
.replace(/[.\-_/]+([a-zA-Z])/g, (_, w) => w.toUpperCase())
|
||||
// drop invalid first characters
|
||||
.replace(/^[^a-zA-Z$_]+/, '');
|
||||
.replace(/^[^a-zA-Z$_]+/, '')
|
||||
// drop version or tag
|
||||
.replace(/@.*$/, '');
|
||||
return `${ident[0].toLowerCase()}${ident.slice(1)}`;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue