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

Action type: "modify"'s pattern property should be built as a Handlebars template #406

Closed
sethidden opened this issue Nov 23, 2023 · 1 comment

Comments

@sethidden
Copy link

sethidden commented Nov 23, 2023

Say you want to turn:

// many other similar looking imports above, but I want to modify specifically {{ importName }}
import {
 foo,
 bar,
} from './{{ importName }}'

into

import {
 foo,
 bar,
 {{ methodName }}, // baz
} from './{{ importName }}'

To do that, you'll need to do

actions: (data) => [
  {
    type: "modify",
    pattern: `} from "./${data.importName}";`,
    path: "src/index.ts",
    template: '  {{methodName}},\n} from "./{{ importName }}";',
  },
]

What I'm proposing is that this should be possible to do without having to turn the "actions" array into a function that returns an array. Above it's done purely to create my own dynamic template for the pattern property because pattern is not transformed using Handlebars, so I need to do it manually using data.methodName

Alternatively, you can close this issue and tell me to reorganize my imports in such a way where this magic isn't necessary :P

@sethidden sethidden changed the title Build type: "modify"'s pattern property should be built as a Handlebars template Action type: "modify"'s pattern property should be built as a Handlebars template Nov 23, 2023
@sethidden
Copy link
Author

Stale

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

No branches or pull requests

1 participant