aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/danger/clean
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /scripts/danger/clean
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'scripts/danger/clean')
-rw-r--r--scripts/danger/clean/cleaner.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/scripts/danger/clean/cleaner.ts b/scripts/danger/clean/cleaner.ts
index d1dba4650..d80b8d323 100644
--- a/scripts/danger/clean/cleaner.ts
+++ b/scripts/danger/clean/cleaner.ts
@@ -1,25 +1,28 @@
1import * as eachSeries from 'async/eachSeries'
2import * as rimraf from 'rimraf' 1import * as rimraf from 'rimraf'
2import * as Promise from 'bluebird'
3 3
4import { CONFIG } from '../../../server/initializers/constants' 4import { CONFIG } from '../../../server/initializers/constants'
5import { database as db } from '../../../server/initializers/database' 5import { database as db } from '../../../server/initializers/database'
6 6
7db.init(true, function () { 7db.init(true)
8 db.sequelize.drop().asCallback(function (err) { 8 .then(() => {
9 if (err) throw err 9 return db.sequelize.drop()
10 10 })
11 .then(() => {
11 console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME) 12 console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME)
12 13
13 const STORAGE = CONFIG.STORAGE 14 const STORAGE = CONFIG.STORAGE
14 eachSeries(Object.keys(STORAGE), function (storage, callbackEach) { 15 Promise.mapSeries(Object.keys(STORAGE), storage => {
15 const storageDir = STORAGE[storage] 16 const storageDir = STORAGE[storage]
16 17
17 rimraf(storageDir, function (err) { 18 return new Promise((res, rej) => {
18 console.info('%s deleted.', storageDir) 19 rimraf(storageDir, function (err) {
19 return callbackEach(err) 20 if (err) return rej(err)
21
22 console.info('%s deleted.', storageDir)
23 return res()
24 })
20 }) 25 })
21 }, function () {
22 process.exit(0)
23 }) 26 })
27 .then(() => process.exit(0))
24 }) 28 })
25})