2016-12-27 18:33:38 +01:00
|
|
|
const eachSeries = require('async/eachSeries')
|
2016-10-13 21:45:23 +02:00
|
|
|
const rimraf = require('rimraf')
|
|
|
|
|
|
|
|
const constants = require('../../../server/initializers/constants')
|
2016-12-25 09:44:13 +01:00
|
|
|
const db = require('../../../server/initializers/database')
|
2016-10-13 21:45:23 +02:00
|
|
|
|
2016-12-25 09:44:13 +01:00
|
|
|
db.init(true, function () {
|
|
|
|
db.sequelize.drop().asCallback(function (err) {
|
|
|
|
if (err) throw err
|
2016-10-13 21:45:23 +02:00
|
|
|
|
2016-12-25 09:44:13 +01:00
|
|
|
console.info('Tables of %s deleted.', db.sequelize.config.database)
|
2016-10-13 21:45:23 +02:00
|
|
|
|
2016-12-25 09:44:13 +01:00
|
|
|
const STORAGE = constants.CONFIG.STORAGE
|
2016-12-27 18:33:38 +01:00
|
|
|
eachSeries(Object.keys(STORAGE), function (storage, callbackEach) {
|
2016-12-25 09:44:13 +01:00
|
|
|
const storageDir = STORAGE[storage]
|
|
|
|
|
|
|
|
rimraf(storageDir, function (err) {
|
2016-12-27 18:33:38 +01:00
|
|
|
console.info('%s deleted.', storageDir)
|
|
|
|
return callbackEach(err)
|
2016-12-25 09:44:13 +01:00
|
|
|
})
|
2016-12-27 18:33:38 +01:00
|
|
|
}, function () {
|
|
|
|
process.exit(0)
|
2016-12-25 09:44:13 +01:00
|
|
|
})
|
2016-10-13 21:45:23 +02:00
|
|
|
})
|
|
|
|
})
|