diff options
Diffstat (limited to 'scripts/danger/clean')
-rw-r--r-- | scripts/danger/clean/cleaner.ts | 27 |
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 @@ | |||
1 | import * as eachSeries from 'async/eachSeries' | ||
2 | import * as rimraf from 'rimraf' | 1 | import * as rimraf from 'rimraf' |
2 | import * as Promise from 'bluebird' | ||
3 | 3 | ||
4 | import { CONFIG } from '../../../server/initializers/constants' | 4 | import { CONFIG } from '../../../server/initializers/constants' |
5 | import { database as db } from '../../../server/initializers/database' | 5 | import { database as db } from '../../../server/initializers/database' |
6 | 6 | ||
7 | db.init(true, function () { | 7 | db.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 | }) | ||