mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-31 02:26:50 +10:00
Show error if .env file is missing when running yarn run dev
This commit is contained in:
parent
6aa2170f84
commit
1119d51b97
2 changed files with 25 additions and 12 deletions
|
|
@ -66,7 +66,8 @@
|
|||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf build/*",
|
||||
"dev": "sharetribe-scripts start",
|
||||
"config": "node scripts/config.js",
|
||||
"dev": "node scripts/config.js --check && sharetribe-scripts start",
|
||||
"build": "sharetribe-scripts build",
|
||||
"format": "prettier --write '**/*.{js,css}'",
|
||||
"format-ci": "prettier --list-different '**/*.{js,css}'",
|
||||
|
|
@ -77,8 +78,7 @@
|
|||
"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",
|
||||
"config": "node scripts/config.js"
|
||||
"translate": "node scripts/translations.js"
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
|
|
|
|||
|
|
@ -132,15 +132,28 @@ const createEnvFile = () => {
|
|||
};
|
||||
|
||||
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.`
|
||||
);
|
||||
if (process.argv[2] && process.argv[2] === '--check') {
|
||||
if (!fs.existsSync(`./.env`)) {
|
||||
process.on('exit', code => {
|
||||
console.log(`
|
||||
|
||||
${chalk.bold.red(`You don't have required .env file!`)}
|
||||
|
||||
Some environment variables are required before starting the app. You can create the .env file and configure the variables by running ${chalk.cyan.bold(
|
||||
'yarn run config'
|
||||
)}
|
||||
|
||||
`);
|
||||
});
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (fs.existsSync(`./.env`)) {
|
||||
console.log(`
|
||||
.env file already exists. You can edit the variables directly from the file. Remember to restart the application after editing the environment variables!
|
||||
|
||||
`);
|
||||
} else {
|
||||
createEnvFile();
|
||||
|
||||
console.log(chalk.yellow.bold(`Required variables:`));
|
||||
|
|
@ -166,7 +179,7 @@ ${chalk.green.bold('Environment variables saved succesfully!')}
|
|||
|
||||
Note that the .env file is a hidden file so it might not be visible directly in directory listing. If you want to update the environment variables you need to edit the file. Remember to restart the application after editing the environment variables!
|
||||
|
||||
Start the Flex template application by running ${chalk.cyan('yarn run dev')}
|
||||
Start the Flex template application by running ${chalk.bold.cyan('yarn run dev')}
|
||||
`);
|
||||
});
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue