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

26 lines
726 B
TypeScript
Raw Normal View History

2017-06-11 13:19:43 +00:00
import * as eachSeries from 'async/eachSeries'
import * as rimraf from 'rimraf'
2016-10-13 19:45:23 +00:00
2017-06-11 13:19:43 +00:00
import { CONFIG } from '../../../server/initializers/constants'
import { database as db } from '../../../server/initializers/database'
2016-10-13 19:45:23 +00:00
2016-12-25 08:44:13 +00:00
db.init(true, function () {
db.sequelize.drop().asCallback(function (err) {
if (err) throw err
2016-10-13 19:45:23 +00:00
2017-06-11 13:19:43 +00:00
console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
2016-10-13 19:45:23 +00:00
2017-06-11 13:19:43 +00:00
const STORAGE = CONFIG.STORAGE
eachSeries(Object.keys(STORAGE), function (storage, callbackEach) {
2016-12-25 08:44:13 +00:00
const storageDir = STORAGE[storage]
rimraf(storageDir, function (err) {
console.info('%s deleted.', storageDir)
return callbackEach(err)
2016-12-25 08:44:13 +00:00
})
}, function () {
process.exit(0)
2016-12-25 08:44:13 +00:00
})
2016-10-13 19:45:23 +00:00
})
})