diff options
Diffstat (limited to 'scripts/danger/clean/cleaner.js')
-rw-r--r-- | scripts/danger/clean/cleaner.js | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/scripts/danger/clean/cleaner.js b/scripts/danger/clean/cleaner.js index 10e91e700..d1e218145 100644 --- a/scripts/danger/clean/cleaner.js +++ b/scripts/danger/clean/cleaner.js | |||
@@ -1,24 +1,23 @@ | |||
1 | const rimraf = require('rimraf') | 1 | const rimraf = require('rimraf') |
2 | const mongoose = require('mongoose') | ||
3 | mongoose.Promise = global.Promise | ||
4 | 2 | ||
5 | const constants = require('../../../server/initializers/constants') | 3 | const constants = require('../../../server/initializers/constants') |
4 | const db = require('../../../server/initializers/database') | ||
6 | 5 | ||
7 | const mongodbUrl = 'mongodb://' + constants.CONFIG.DATABASE.HOSTNAME + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME | 6 | db.init(true, function () { |
8 | mongoose.connect(mongodbUrl, function () { | 7 | db.sequelize.drop().asCallback(function (err) { |
9 | console.info('Deleting MongoDB %s database.', constants.CONFIG.DATABASE.DBNAME) | 8 | if (err) throw err |
10 | mongoose.connection.dropDatabase(function () { | ||
11 | mongoose.connection.close() | ||
12 | }) | ||
13 | }) | ||
14 | 9 | ||
15 | const STORAGE = constants.CONFIG.STORAGE | 10 | console.info('Tables of %s deleted.', db.sequelize.config.database) |
16 | Object.keys(STORAGE).forEach(function (storage) { | ||
17 | const storageDir = STORAGE[storage] | ||
18 | 11 | ||
19 | rimraf(storageDir, function (err) { | 12 | const STORAGE = constants.CONFIG.STORAGE |
20 | if (err) throw err | 13 | Object.keys(STORAGE).forEach(function (storage) { |
14 | const storageDir = STORAGE[storage] | ||
15 | |||
16 | rimraf(storageDir, function (err) { | ||
17 | if (err) throw err | ||
21 | 18 | ||
22 | console.info('Deleting %s.', storageDir) | 19 | console.info('Deleting %s.', storageDir) |
20 | }) | ||
21 | }) | ||
23 | }) | 22 | }) |
24 | }) | 23 | }) |