mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Fix v4 migration when no existing .env
This commit is contained in:
parent
020d559667
commit
6e604706b8
|
|
@ -37,7 +37,9 @@ module.exports = {
|
|||
|
||||
const envFile = path.resolve(__dirname, '../../../.env');
|
||||
|
||||
const env = fs.existsSync(envFile) ? dotenv.parse(fs.readFileSync(envFile)) : {};
|
||||
const envFileExists = fs.existsSync(envFile);
|
||||
|
||||
const env = envFileExists ? dotenv.parse(fs.readFileSync(envFile)) : {};
|
||||
|
||||
const oldSystem = sequelize.define('rdioScannerSystem', {
|
||||
aliases: {
|
||||
|
|
@ -76,6 +78,7 @@ module.exports = {
|
|||
|
||||
let systems;
|
||||
|
||||
if (envFileExists) {
|
||||
try {
|
||||
systems = await oldSystem.findAll({ order: [['system', 'ASC']] });
|
||||
|
||||
|
|
@ -99,6 +102,10 @@ module.exports = {
|
|||
systems = getExampleSystems();
|
||||
}
|
||||
|
||||
} else {
|
||||
systems = getExampleSystems();
|
||||
}
|
||||
|
||||
const config = {
|
||||
nodejs: {
|
||||
env: env.NODE_ENV || 'production',
|
||||
|
|
@ -128,8 +135,10 @@ module.exports = {
|
|||
|
||||
fs.writeFileSync(configFile, JSON.stringify(config, null, 4));
|
||||
|
||||
if (fs.existsSync(envFile)) {
|
||||
fs.unlinkSync(envFile);
|
||||
}
|
||||
}
|
||||
|
||||
const transaction = await sequelize.transaction();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue