2017-06-11 08:19:43 -05:00
|
|
|
import * as rimraf from 'rimraf'
|
2017-07-05 06:26:25 -05:00
|
|
|
import * as Promise from 'bluebird'
|
2016-10-13 14:45:23 -05:00
|
|
|
|
2017-06-11 08:19:43 -05:00
|
|
|
import { CONFIG } from '../../../server/initializers/constants'
|
|
|
|
import { database as db } from '../../../server/initializers/database'
|
2016-10-13 14:45:23 -05:00
|
|
|
|
2017-07-05 06:26:25 -05:00
|
|
|
db.init(true)
|
|
|
|
.then(() => {
|
|
|
|
return db.sequelize.drop()
|
|
|
|
})
|
|
|
|
.then(() => {
|
2017-06-11 08:19:43 -05:00
|
|
|
console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
|
2016-10-13 14:45:23 -05:00
|
|
|
|
2017-06-11 08:19:43 -05:00
|
|
|
const STORAGE = CONFIG.STORAGE
|
2017-07-05 06:26:25 -05:00
|
|
|
Promise.mapSeries(Object.keys(STORAGE), storage => {
|
2016-12-25 02:44:13 -06:00
|
|
|
const storageDir = STORAGE[storage]
|
|
|
|
|
2017-07-05 06:26:25 -05:00
|
|
|
return new Promise((res, rej) => {
|
2017-09-07 08:27:35 -05:00
|
|
|
rimraf(storageDir, err => {
|
2017-07-05 06:26:25 -05:00
|
|
|
if (err) return rej(err)
|
|
|
|
|
|
|
|
console.info('%s deleted.', storageDir)
|
|
|
|
return res()
|
|
|
|
})
|
2016-12-25 02:44:13 -06:00
|
|
|
})
|
|
|
|
})
|
2017-07-05 06:26:25 -05:00
|
|
|
.then(() => process.exit(0))
|
2016-10-13 14:45:23 -05:00
|
|
|
})
|