2016-09-06 15:21:25 +00:00
|
|
|
import 'typings-global'
|
|
|
|
import plugins = require('./npmts.plugins')
|
|
|
|
import paths = require('./npmts.paths')
|
2016-09-29 14:19:49 +00:00
|
|
|
import { npmtsOra } from './npmts.promisechain'
|
2016-03-21 00:07:34 +00:00
|
|
|
|
2016-09-29 14:19:49 +00:00
|
|
|
/**
|
|
|
|
* removes the dist directory which will be entirely rebuild
|
|
|
|
*/
|
|
|
|
let removeDist = function () {
|
2016-09-06 15:21:25 +00:00
|
|
|
npmtsOra.text('cleaning dist folder')
|
|
|
|
return plugins.smartfile.fs.remove(paths.distDir)
|
|
|
|
}
|
2016-05-19 20:11:18 +00:00
|
|
|
|
2016-09-29 14:19:49 +00:00
|
|
|
/**
|
|
|
|
* remove .d.ts files from testDirctory
|
|
|
|
*/
|
|
|
|
let removeTestDeclarations = function () {
|
|
|
|
let done = plugins.q.defer()
|
|
|
|
plugins.smartfile.fs.listFileTree('./test/', '**/*.d.ts').then(fileArray => {
|
|
|
|
let fileArrayToRemove = plugins.smartpath.transform.toAbsolute(fileArray, process.cwd() + '//test/')
|
|
|
|
plugins.smartfile.fs.removeManySync(fileArrayToRemove)
|
|
|
|
done.resolve()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* remove old pages
|
|
|
|
*/
|
|
|
|
let removePages = function () {
|
2016-09-06 15:21:25 +00:00
|
|
|
npmtsOra.text('cleaning pages folder')
|
|
|
|
return plugins.smartfile.fs.remove(paths.pagesDir)
|
|
|
|
}
|
2016-05-19 20:11:18 +00:00
|
|
|
|
2016-09-29 14:19:49 +00:00
|
|
|
export let run = function (configArg) {
|
2016-09-06 15:21:25 +00:00
|
|
|
npmtsOra.text('cleaning up from previous builds...')
|
2016-09-22 21:23:16 +00:00
|
|
|
let done = plugins.q.defer()
|
2016-05-19 20:11:18 +00:00
|
|
|
removeDist()
|
2016-09-29 14:19:49 +00:00
|
|
|
.then(removeTestDeclarations)
|
2016-08-30 15:57:51 +00:00
|
|
|
.then(removePages)
|
2016-09-29 14:19:49 +00:00
|
|
|
.then(function () {
|
2016-09-06 15:21:25 +00:00
|
|
|
plugins.beautylog.ok('Cleaned up from previous builds!')
|
|
|
|
done.resolve(configArg)
|
|
|
|
})
|
|
|
|
return done.promise
|
|
|
|
}
|