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

Changing merge strategy #298

Closed
Kastrylia opened this issue Oct 12, 2023 · 7 comments
Closed

Changing merge strategy #298

Kastrylia opened this issue Oct 12, 2023 · 7 comments

Comments

@Kastrylia
Copy link

Kastrylia commented Oct 12, 2023

Greetings! Is it possible to change merge strategy? I want to fully replace a file when applying new version of the config.

At the moment if I have the following in my main project's .prettierrc.json:
{
"tabWidth": 2,
"test": "test"
}
And the following in the corresponding file in the repo of the updated config:
{
"test": "test"
}

After installing new package and applying it via "npx sharec" I expect it to be:
{
"test": "test"
}
But in reality it results in:
{
"tabWidth": 2,
"test": "test"
}

The package's version is "3.2.1",

@epszaw
Copy link
Member

epszaw commented Oct 12, 2023

Hello! It's possible to do using hooks. Try to replace prettier file by upcoming one in mergedConfigs. Just play around context to see all data it has.

@Kastrylia
Copy link
Author

Kastrylia commented Oct 12, 2023

So, basically, I have to substitute content of ${pathOfInstalledConfigPackage}/.prettierrc.json to context.mergedConfigs[pathOfMyConfigFile] in "After merge" hook, right?

@Kastrylia
Copy link
Author

Kastrylia commented Oct 12, 2023

Furthermore, is it possible to deliver ".sharecrc.js" within the same config package? Or the file with hooks should be added manually for every repo that uses the config?

@epszaw
Copy link
Member

epszaw commented Oct 12, 2023

So, basically, I have to substitute content of ${pathOfInstalledConfigPackage}/.prettierrc.json to context.mergedConfigs[pathOfMyConfigFile] in "After merge" hook, right?

That's right.

Furthermore, is it possible to deliver ".sharecrc.js" within the same config package? Or the file with hooks should be added manually for every repo that uses the config?

Of course, you can, but updated version will be applied for next merge, not for current one.

@Kastrylia
Copy link
Author

Ok, so there is .sharercrc.js in my repo's node_modules/my-config. When i do "npx sharec" from the root of my project the hook doesn't work. When I move it to the project's root - everything works well. Is it possible to configure sharec to get hooks from package folder?

@epszaw
Copy link
Member

epszaw commented Oct 12, 2023

At this moment sharec supports only root configuration file

@Kastrylia
Copy link
Author

Much obliged! Have a nice day!

@epszaw epszaw closed this as completed Oct 12, 2023
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

2 participants