fix: use fs-jetpack in scripts/migrate.js

This commit is contained in:
Bobby 2022-10-04 07:13:36 +07:00
parent d4234261b3
commit ebd53996d7
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -1,4 +1,4 @@
const paths = require('./../controllers/pathsController')
const jetpack = require('fs-jetpack')
const perms = require('./../controllers/permissionController')
const config = require('./../config')
@ -22,14 +22,9 @@ const map = {
;(async () => {
if (['better-sqlite3', 'sqlite3'].includes(config.database.client)) {
try {
await paths.access(config.database.connection.filename)
} catch (err) {
if (err.code === 'ENOENT') {
console.log('Sqlite3 database file missing. Assumes first install, migration skipped.')
process.exit(0)
}
throw err
if (!await jetpack.existsAsync(config.database.connection.filename)) {
console.log('Sqlite3 database file missing. Assumes first install, migration skipped.')
process.exit(0)
}
}