-
Notifications
You must be signed in to change notification settings - Fork 0
/
container.js
42 lines (33 loc) · 1.06 KB
/
container.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
const fs = require("fs");
const logSymbols = require('log-symbols');
let currentDir = process.cwd();
let containerName = process.argv[3];
const app = {}
app.createContainer = function () {
fs.mkdir(currentDir + '/src/containers/' + containerName + '/', { recursive: true }, (err) => {
if (err) throw err;
let data = `import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
class ${containerName} extends PureComponent {
constructor(props) {
super(props);
}
render() {
return <div>
<p>{"${containerName}"}</p>
</div>
}
}
const mapStateToProps = (state) => {
return {
}
}
export default connect(mapStateToProps, {
})(${containerName})`;
fs.writeFile(currentDir + '/src/containers/' + containerName + '/' + "index.jsx", data, function (err, data) {
if (err) console.log(err);
console.log(logSymbols.success, '\x1b[32m' + `Container ${containerName} file created successfully` + '\x1b[0m');
});
});
}
module.exports = app;