aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/danger/clean/cleaner.js
blob: d1e2181452d23bae25e515446a38a7c83f95d941 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const rimraf = require('rimraf')

const constants = require('../../../server/initializers/constants')
const db = require('../../../server/initializers/database')

db.init(true, function () {
  db.sequelize.drop().asCallback(function (err) {
    if (err) throw err

    console.info('Tables of %s deleted.', db.sequelize.config.database)

    const STORAGE = constants.CONFIG.STORAGE
    Object.keys(STORAGE).forEach(function (storage) {
      const storageDir = STORAGE[storage]

      rimraf(storageDir, function (err) {
        if (err) throw err

        console.info('Deleting %s.', storageDir)
      })
    })
  })
})