mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-16 09:53: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 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', {
|
const oldSystem = sequelize.define('rdioScannerSystem', {
|
||||||
aliases: {
|
aliases: {
|
||||||
|
|
@ -76,6 +78,7 @@ module.exports = {
|
||||||
|
|
||||||
let systems;
|
let systems;
|
||||||
|
|
||||||
|
if (envFileExists) {
|
||||||
try {
|
try {
|
||||||
systems = await oldSystem.findAll({ order: [['system', 'ASC']] });
|
systems = await oldSystem.findAll({ order: [['system', 'ASC']] });
|
||||||
|
|
||||||
|
|
@ -99,6 +102,10 @@ module.exports = {
|
||||||
systems = getExampleSystems();
|
systems = getExampleSystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
systems = getExampleSystems();
|
||||||
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
nodejs: {
|
nodejs: {
|
||||||
env: env.NODE_ENV || 'production',
|
env: env.NODE_ENV || 'production',
|
||||||
|
|
@ -128,8 +135,10 @@ module.exports = {
|
||||||
|
|
||||||
fs.writeFileSync(configFile, JSON.stringify(config, null, 4));
|
fs.writeFileSync(configFile, JSON.stringify(config, null, 4));
|
||||||
|
|
||||||
|
if (fs.existsSync(envFile)) {
|
||||||
fs.unlinkSync(envFile);
|
fs.unlinkSync(envFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const transaction = await sequelize.transaction();
|
const transaction = await sequelize.transaction();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue