mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-25 22:37:18 +10:00
Create .env file if it doesn't exist
This commit is contained in:
parent
19357e6548
commit
04a16fe8fe
2 changed files with 29 additions and 1 deletions
|
|
@ -77,7 +77,8 @@
|
|||
"start": "node server/index.js",
|
||||
"dev-server": "export NODE_ENV=development PORT=4000 REACT_APP_CANONICAL_ROOT_URL=http://localhost:4000&&yarn run build&&nodemon --watch server server/index.js",
|
||||
"heroku-postbuild": "yarn run build",
|
||||
"translate": "node scripts/translations.js"
|
||||
"translate": "node scripts/translations.js",
|
||||
"config": "node scripts/config.js"
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
|
|
|
|||
27
scripts/config.js
Normal file
27
scripts/config.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
const fs = require('fs');
|
||||
const chalk = require('chalk');
|
||||
|
||||
|
||||
|
||||
const createEnvFile = () => {
|
||||
fs.copyFileSync('./.env-template', './.env', err => {
|
||||
if (err) throw err;
|
||||
});
|
||||
};
|
||||
|
||||
const run = () => {
|
||||
if (fs.existsSync(`./.env`)) {
|
||||
console.log(
|
||||
`.env file already exists. You can edit the variables directly in that file. Remember to restart the application after editing the environment variables!`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`You don't have .env file yet. With this tool you can configure required enviroment variables and create .env file automatically.`
|
||||
);
|
||||
|
||||
createEnvFile();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
Loading…
Add table
Reference in a new issue