I have limited knowledge in git to understand the documentation on git-hooks
. I wanted to know if there is a way to add a git-hook
or some other construct such that it can check whether some code is present/commented out in one of the files. My workflow is that I have a configuration file globalConfig.js
which contains two set of configurations development
and production
. When I am developing, I uncomment out the development
configuration and comment out production
configuration but when I commit any code to my repo, I want to make sure that the production
configuration is uncommented and development
configuration is commented.
Excerpt from globalConfig.js file
Development
// Production config - Always uncomment it before commiting
// const firebaseConfig = {
// apiKey: "prod",
// authDomain: "prod",
// databaseURL: "prod",
// storageBucket: "prod",
// messagingSenderId: "prod"
// };
// Dev config - Always comment out before commiting
const firebaseConfig = {
apiKey: "dev",
authDomain: "dev",
databaseURL: "dev",
storageBucket: "dev",
messagingSenderId: "dev"
};
Production
// Production config - Always uncomment it before commiting
const firebaseConfig = {
apiKey: "prod",
authDomain: "prod",
databaseURL: "prod",
storageBucket: "prod",
messagingSenderId: "prod"
};
// Dev config - Always comment out before commiting
// const firebaseConfig = {
// apiKey: "dev",
// authDomain: "dev",
// databaseURL: "dev",
// storageBucket: "dev",
// messagingSenderId: "dev"
//};
Is it possible to achieve it via git-hook
or some other git construct?