forked from botpress/botpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
executable file
·51 lines (41 loc) · 1.36 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const mkdirp = require('mkdirp')
const ncp = require('ncp').ncp
const rimraf = require('rimraf')
const Promise = require('bluebird')
const webpackJs = require('./webpack.js')
var EMAIL_TPL = './extensions/enterprise/pro/emails/templates'
var BOTPRESS_EDITION = process.env.BOTPRESS_EDITION
const rimrafAsync = Promise.promisify(rimraf)
const mkdirpAsync = Promise.promisify(mkdirp)
const ncpAsync = Promise.promisify(ncp)
const webpackAsync = Promise.promisify(webpackJs.run)
const cleanOldBuild = () => {
console.log('Cleaning old build')
// call: rm -rf lib/
return rimrafAsync('./lib')
}
const copyEmailTemplates = async () => {
if (BOTPRESS_EDITION === 'pro' || BOTPRESS_EDITION === 'ultimate') {
console.log('Copying email templates')
// call: mkdir -p lib/emails/templates
await mkdirpAsync('./lib/emails/templates')
// call: cp -a
await ncpAsync(EMAIL_TPL, './lib/emails/templates')
}
}
const bundleApp = async () => {
console.log('Bundling app...')
//node webpack.js --compile
await webpackAsync()
console.log('Copying templates')
// call: mkdir -p lib/cli/templates
await mkdirpAsync('./lib/cli/templates')
// call: cp -a
await ncpAsync('./src/cli/templates', './lib/cli/templates')
}
const build = async () => {
await cleanOldBuild()
await copyEmailTemplates()
await bundleApp()
}
build().then(() => process.exit(0))