-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-env.js
More file actions
18 lines (18 loc) · 850 Bytes
/
install-env.js
File metadata and controls
18 lines (18 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const dotenv = require('dotenv');
const path = require('path');
const fs = require('fs');
const dirEnv = path.join(process.cwd(), '/.env');
dotenv.config({path: '.env'});
const contentEnv = 'MONGODB_URI=mongodb://localhost:27017/test \nMAILVERIF=Gmail \nURLVERIF=http://example.com/email-verification/${URL} \nMAILACCOUNT= \nMAILPASS= \nCLIENTID= \nACCESSTOKEN= \nREFRESHTOKEN= \nCLIENTSECRET= \nSECRET_TOKEN=social\nSECRET_KEYCAPTCHA= \nEMAIL_VERIFICATION=false';
try {
fs.statSync(dirEnv).isFile();
} catch (err) {
if (err.code === 'ENOENT') {
if (!process.env.MONGODB_URI) {
console.log('environment file does not exist, please fulfill the information in the dot env file at the root folder');
fs.writeFileSync(dirEnv, contentEnv, 'utf8');
}
}
} finally {
console.log('end of the procedure of environment creation');
}