aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/danger/clean/cleaner.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/danger/clean/cleaner.ts')
-rw-r--r--scripts/danger/clean/cleaner.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/danger/clean/cleaner.ts b/scripts/danger/clean/cleaner.ts
new file mode 100644
index 000000000..d1dba4650
--- /dev/null
+++ b/scripts/danger/clean/cleaner.ts
@@ -0,0 +1,25 @@
1import * as eachSeries from 'async/eachSeries'
2import * as rimraf from 'rimraf'
3
4import { CONFIG } from '../../../server/initializers/constants'
5import { database as db } from '../../../server/initializers/database'
6
7db.init(true, function () {
8 db.sequelize.drop().asCallback(function (err) {
9 if (err) throw err
10
11 console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
12
13 const STORAGE = CONFIG.STORAGE
14 eachSeries(Object.keys(STORAGE), function (storage, callbackEach) {
15 const storageDir = STORAGE[storage]
16
17 rimraf(storageDir, function (err) {
18 console.info('%s deleted.', storageDir)
19 return callbackEach(err)
20 })
21 }, function () {
22 process.exit(0)
23 })
24 })
25})