PeerTube/scripts/danger/clean/cleaner.js

25 lines
783 B
JavaScript
Raw Normal View History

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