forked from codeday-init-2022-spring/fastify-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheject.js
More file actions
36 lines (31 loc) · 633 Bytes
/
eject.js
File metadata and controls
36 lines (31 loc) · 633 Bytes
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
'use strict'
const path = require('path')
const generify = require('generify')
const log = require('./log')
function eject (dir) {
return new Promise((resolve, reject) => {
generify(path.join(__dirname, 'templates', 'eject'), dir, {}, function (file) {
log('debug', `generated ${file}`)
}, function (err) {
if (err) {
return reject(err)
}
resolve()
})
})
}
function cli () {
eject(process.cwd()).catch(function (err) {
if (err) {
log('error', err.message)
process.exit(1)
}
})
}
module.exports = {
eject,
cli
}
if (require.main === module) {
cli()
}