1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-21 07:41:39 +03:00
leon/scripts/setup/setup-dotenv.js

40 lines
835 B
JavaScript
Raw Normal View History

2019-02-10 15:26:50 +03:00
import { prompt } from 'inquirer'
import fs from 'fs'
import { log } from '@/helpers/log'
2019-02-10 15:26:50 +03:00
/**
* Duplicate the .env.sample to .env file
*/
2022-09-03 14:12:41 +03:00
export default () =>
new Promise(async (resolve) => {
log.info('.env file creation...')
const createDotenv = () => {
fs.createReadStream('.env.sample').pipe(fs.createWriteStream('.env'))
log.success('.env file created')
2019-02-10 15:26:50 +03:00
}
2022-09-03 14:12:41 +03:00
if (!fs.existsSync('.env')) {
createDotenv()
resolve()
} else if (process.env.IS_DOCKER === 'true') {
resolve()
} else {
const answer = await prompt({
type: 'confirm',
name: 'dotenv.overwrite',
message: '.env file already exists, overwrite:',
default: false
})
if (answer.dotenv.overwrite === true) {
createDotenv()
}
resolve()
}
})