Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively copy the template folder #74

Merged
merged 2 commits into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
},
"devDependencies": {
"bundle-deps": "^1.0.0",
"fs-extra": "^0.30.0",
"react": "^15.2.1",
"react-dom": "^15.2.1"
},
Expand Down
24 changes: 3 additions & 21 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

var fs = require('fs');
var fs = require('fs-extra');
var path = require('path');
var spawn = require('cross-spawn');

Expand Down Expand Up @@ -35,25 +35,7 @@ module.exports = function(hostPath, appName, verbose) {
);

// Copy the files for the user
function copySync(src, dest) {
return fs.writeFileSync(dest, fs.readFileSync(src));
}
fs.mkdirSync(path.join(hostPath, 'src'));
fs.readdirSync(path.join(selfPath, 'template/src')).forEach(function(filename) {
copySync(
path.join(selfPath, 'template/src', filename),
path.join(hostPath, 'src', filename)
);
});
fs.readdirSync(path.join(selfPath, 'template')).forEach(function(filename) {
if (fs.lstatSync(path.join(selfPath, 'template', filename)).isDirectory()) {
return
}
copySync(
path.join(selfPath, 'template', filename),
path.join(hostPath, filename)
);
});
fs.copySync(path.join(selfPath, 'template'), hostPath);

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

// Make sure to display the right way to cd
var cdpath;
if (path.join(process.cwd(), appName) == hostPath) {
if (path.join(process.cwd(), appName) === hostPath) {
cdpath = appName;
} else {
cdpath = hostPath;
Expand Down