Closed CVarisco closed 7 years ago
Hey @CVarisco, that's a great feature that I will really appreciate to use. I will try to figure this out and open a PR.
But first, I have some suggestions. What do you think about pass just the prefix used in the file name to config? Like this:
{
...
file_name: {
test: 'test', //or
test: 'spec', // or
etc
}
}
I think this way will be better to deal with the name and extension of the file, and just do something like this to generate the name of the file:
fs.outputFile(`${destination}/${name}.{testPrefix}.${jsExtension}`, generateTestTemplate(name))
What do you think?
Hi @iagodahlem, thanks to your support 🙂
What do you think if the user can choose in base the name and the testPrefix ? Example:
{
...
file_name: {
testPrefix: 'test', //or
test: 'COMPONENT_NAME',
etc
}
}
And, what do you think if the user can use the constant COMPONENT_NAME
to be replaced on the file_name
config object ?
Example with component name = MyComponent
{
...
file_name: {
testPrefix: 'test', //or
test: 'COMPONENT_NAME',
component: 'Button',
etc
}
}
Results:
MyComponent.test.js
Button.js
Understand what I mean ? Thanks again 🌮
Hey @CVarisco! I thank you man.
I guess that I get it. So let's see, your idea is, let user pass some optional options to _filename property, being some of this options:
testPrefix
: Overrides the match word used on test files, for instance.test
: Overrides the name used on test files.component
: Override the name used on the component file itself.What do you think? Do you have any other option in mind? Let's try to get and document all possible options that we want to add.
Another suggestions that I have for the options name, tell me what you think:
testFileMatch
, instead of testPrefix
, default value to test.testFileName
, instead of test
, default value to _COMPONENTNAME.componentFileName
, instead of component
, default to _COMPONENTNAME.So we use like this:
{
"fileNames": {
"testFileMatch": "spec"
}
}
Yeah 🎉 And also the style file name is a good option to add.
So:
{
"fileNames": {
"testFileMatch": "spec",
"testFileName": "myTest", // default value to COMPONENT_NAME.
"componentFileName": "component", // default value to COMPONENT_NAME.
"styleFileName": "styles", // default to COMPONENT_NAME.
}
}
Is it ok for you ?
Yes.
That's great to me.
Let's do this.
:metal: :metal: :metal:
Hi !
I'm working on it on filenames-feature branch 📇
Adds the ability to the user to insert the file name. Something like this in the config:
thanks to @viktorbergehall