]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/danger/clean/cleaner.ts
Merge branch 'master' into develop
[github/Chocobozzz/PeerTube.git] / scripts / danger / clean / cleaner.ts
CommitLineData
6fcd19ba 1import * as Promise from 'bluebird'
3fd3ab2d 2import * as rimraf from 'rimraf'
74dc3bca
C
3import { initDatabaseModels, sequelizeTypescript } from '../../../server/initializers'
4import { CONFIG } from '../../../server/initializers/config'
82221ac9 5
91fea9fc 6initDatabaseModels(true)
6fcd19ba 7 .then(() => {
3fd3ab2d 8 return sequelizeTypescript.drop()
6fcd19ba
C
9 })
10 .then(() => {
1840c2f7 11 console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
82221ac9 12
1840c2f7 13 const STORAGE = CONFIG.STORAGE
6fcd19ba 14 Promise.mapSeries(Object.keys(STORAGE), storage => {
dd601993
C
15 const storageDir = STORAGE[storage]
16
6fcd19ba 17 return new Promise((res, rej) => {
fdbda9e3 18 rimraf(storageDir, err => {
6fcd19ba
C
19 if (err) return rej(err)
20
21 console.info('%s deleted.', storageDir)
22 return res()
23 })
dd601993
C
24 })
25 })
6fcd19ba 26 .then(() => process.exit(0))
82221ac9 27 })