1
0
Fork 0
peertube/scripts/danger/clean/cleaner.js

24 lines
748 B
JavaScript
Raw Normal View History

2016-10-13 15:45:23 -04:00
const rimraf = require('rimraf')
const mongoose = require('mongoose')
const constants = require('../../../server/initializers/constants')
const mongodbUrl = 'mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME
mongoose.connect(mongodbUrl, function () {
console.info('Deleting MongoDB %s database.', constants.CONFIG.DATABASE.DBNAME)
mongoose.connection.db.dropDatabase(function () {
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)
})
})