-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
43 lines (40 loc) · 840 Bytes
/
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
/* eslint-disable func-names */
const fs = require('fs');
const moment = require('moment');
const currentDir = process.cwd();
const templatePath = 'plop';
const date = moment().format();
const year = moment().format('YYYY');
module.exports = function (plop) {
plop.setGenerator('District', {
description: 'Create a new district',
prompts: [
{
type: 'input',
name: 'title',
message: 'Title',
validate(value) {
if (/.+/.test(value)) {
return true;
}
return 'Title is required';
},
},
],
actions() {
process.chdir(plop.getPlopfilePath());
return [
{
type: 'addMany',
destination: `${currentDir}/src/districts/`,
base: `${templatePath}`,
templateFiles: '**/*.txt',
stripExtensions: ['txt'],
data: {
date,
},
},
];
},
});
};