-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
26 lines (24 loc) · 697 Bytes
/
cli.js
File metadata and controls
26 lines (24 loc) · 697 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
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const inquirer = require('inquirer')
const ejs = require('ejs')
inquirer.prompt([
{
type: 'input',
name: 'projectName',
message: 'Please enter the project name:'
}
]).then(answers => {
const tmpDir = path.join(__dirname, 'templates')
const destDir = process.cwd()
fs.readdir(tmpDir, (err, files) => {
if (err) throw err
files.forEach(file => {
ejs.renderFile(path.join(tmpDir, file), answers, (err, result) => {
if (err) throw err
fs.writeFileSync(path.join(destDir, file), result)
})
})
})
})