-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplopfile.js
43 lines (36 loc) · 1.06 KB
/
plopfile.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
var fs = require('fs-extra')
var path = require('path')
var actions = require('./actions')
function copyFolder(root, dir) {
return async function copyNats() {
let srcPath = path.resolve(__dirname, dir)
let targetPath = path.resolve(root, dir)
try {
await fs.copy(srcPath, targetPath)
return `copied ${srcPath} to ${targetPath}`
} catch (err) {
console.error(err)
return `error on copy ${srcPath}`
}
}
}
// custom actions
function customActions(data, opts = {}) {
return [
copyFolder(data.root, 'nats'),
copyFolder(data.root, 'api')
]
}
var vfs = require('./vfs')
module.exports = (plop, opts = {}) => {
let inputsPath = opts.inputs || './fixtures/single-service'
let data = require(inputsPath)
data = Object.assign(data, {
root: opts.root || 'app',
fsys: vfs(opts)
})
actions.list = actions.list.concat(customActions(data, opts))
let plopConfig = require('./plop-config')(data, actions)
// We declare a new generator called "module"
let generator = plop.setGenerator('docker', plopConfig);
};