2017-06-11 09:19:43 -04:00
|
|
|
import * as eachSeries from 'async/eachSeries'
|
|
|
|
import * as rimraf from 'rimraf'
|
2016-10-13 15:45:23 -04:00
|
|
|
|
2017-06-11 09:19:43 -04:00
|
|
|
import { CONFIG } from '../../../server/initializers/constants'
|
|
|
|
import { database as db } from '../../../server/initializers/database'
|
2016-10-13 15:45:23 -04:00
|
|
|
|
2016-12-25 03:44:13 -05:00
|
|
|
db.init(true, function () {
|
|
|
|
db.sequelize.drop().asCallback(function (err) {
|
|
|
|
if (err) throw err
|
2016-10-13 15:45:23 -04:00
|
|
|
|
2017-06-11 09:19:43 -04:00
|
|
|
console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
|
2016-10-13 15:45:23 -04:00
|
|
|
|
2017-06-11 09:19:43 -04:00
|
|
|
const STORAGE = CONFIG.STORAGE
|
2016-12-27 12:33:38 -05:00
|
|
|
eachSeries(Object.keys(STORAGE), function (storage, callbackEach) {
|
2016-12-25 03:44:13 -05:00
|
|
|
const storageDir = STORAGE[storage]
|
|
|
|
|
|
|
|
rimraf(storageDir, function (err) {
|
2016-12-27 12:33:38 -05:00
|
|
|
console.info('%s deleted.', storageDir)
|
|
|
|
return callbackEach(err)
|
2016-12-25 03:44:13 -05:00
|
|
|
})
|
2016-12-27 12:33:38 -05:00
|
|
|
}, function () {
|
|
|
|
process.exit(0)
|
2016-12-25 03:44:13 -05:00
|
|
|
})
|
2016-10-13 15:45:23 -04:00
|
|
|
})
|
|
|
|
})
|