2016-10-13 21:45:23 +02:00
|
|
|
const rimraf = require('rimraf')
|
|
|
|
const mongoose = require('mongoose')
|
2016-11-14 22:40:33 +01:00
|
|
|
mongoose.Promise = global.Promise
|
2016-10-13 21:45:23 +02:00
|
|
|
|
|
|
|
const constants = require('../../../server/initializers/constants')
|
|
|
|
|
2016-11-14 22:46:04 +01:00
|
|
|
const mongodbUrl = 'mongodb://' + constants.CONFIG.DATABASE.HOSTNAME + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME
|
2016-10-13 21:45:23 +02:00
|
|
|
mongoose.connect(mongodbUrl, function () {
|
|
|
|
console.info('Deleting MongoDB %s database.', constants.CONFIG.DATABASE.DBNAME)
|
2016-11-14 22:40:33 +01:00
|
|
|
mongoose.connection.dropDatabase(function () {
|
2016-10-13 21:45:23 +02:00
|
|
|
mongoose.connection.close()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const STORAGE = constants.CONFIG.STORAGE
|
|
|
|
Object.keys(STORAGE).forEach(function (storage) {
|
|
|
|
const storageDir = STORAGE[storage]
|
|
|
|
|
|
|
|
rimraf(storageDir, function (err) {
|
|
|
|
if (err) throw err
|
|
|
|
|
|
|
|
console.info('Deleting %s.', storageDir)
|
|
|
|
})
|
|
|
|
})
|