Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit ad2550f

Browse files
eanplattervjeux
authored andcommitted
Recursively copy the template folder (#74)
* Recursively copy the template folder * add fs-extra library
1 parent 3740473 commit ad2550f

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
},
5757
"devDependencies": {
5858
"bundle-deps": "^1.0.0",
59+
"fs-extra": "^0.30.0",
5960
"react": "^15.2.1",
6061
"react-dom": "^15.2.1"
6162
},

Diff for: scripts/init.js

+3-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
var fs = require('fs');
10+
var fs = require('fs-extra');
1111
var path = require('path');
1212
var spawn = require('cross-spawn');
1313

@@ -35,25 +35,7 @@ module.exports = function(hostPath, appName, verbose) {
3535
);
3636

3737
// Copy the files for the user
38-
function copySync(src, dest) {
39-
return fs.writeFileSync(dest, fs.readFileSync(src));
40-
}
41-
fs.mkdirSync(path.join(hostPath, 'src'));
42-
fs.readdirSync(path.join(selfPath, 'template/src')).forEach(function(filename) {
43-
copySync(
44-
path.join(selfPath, 'template/src', filename),
45-
path.join(hostPath, 'src', filename)
46-
);
47-
});
48-
fs.readdirSync(path.join(selfPath, 'template')).forEach(function(filename) {
49-
if (fs.lstatSync(path.join(selfPath, 'template', filename)).isDirectory()) {
50-
return
51-
}
52-
copySync(
53-
path.join(selfPath, 'template', filename),
54-
path.join(hostPath, filename)
55-
);
56-
});
38+
fs.copySync(path.join(selfPath, 'template'), hostPath);
5739

5840
// Run another npm install for react and react-dom
5941
console.log('Installing react and react-dom from npm...');
@@ -71,7 +53,7 @@ module.exports = function(hostPath, appName, verbose) {
7153

7254
// Make sure to display the right way to cd
7355
var cdpath;
74-
if (path.join(process.cwd(), appName) == hostPath) {
56+
if (path.join(process.cwd(), appName) === hostPath) {
7557
cdpath = appName;
7658
} else {
7759
cdpath = hostPath;

0 commit comments

Comments
 (0)