-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Conversation
return fs.writeFileSync(dest, fs.readFileSync(src)); | ||
function copyFileSync(src, dest) { | ||
var target = dest; | ||
if (fs.existsSync(dest)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never going to happen right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the file is never going to exist? Yeah I guess not. Updating...
Is there a Node Module(tm) that wraps |
Thanks for doing that. I really hate that the node fs api doesn't has this by default |
@gaearon fs-extra |
I can instead implement fs.extra's copyRecursive method, it probably deals with cross platform issues better than a hand rolled solution. I'll give it a whirl! |
fs.readdirSync(path.join(selfPath, 'template')).forEach(function(filename) { | ||
if (fs.lstatSync(path.join(selfPath, 'template', filename)).isDirectory()) { | ||
return | ||
fs.copyRecursive(path.join(selfPath, 'template'), hostPath, function(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Geez, this was ridiculously easy. thanks @vjeux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know. I'm super angry at node for not providing this by default. Seems like a no-brainer :(
@@ -56,6 +56,8 @@ | |||
}, | |||
"devDependencies": { | |||
"bundle-deps": "^1.0.0", | |||
"fs-extra": "^0.30.0", | |||
"fs.extra": "^1.3.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
Well, I learned a lot from this pr and #33 where I wrestled with this issue, only to find that 1 line of code could have solved it all. Worth it :) Now that we're using the fs-extra library perhaps there are other places where we can clean the code up a little bit. |
/me excited :) |
This seems to be breaking the end to end test "Error: Cannot find module 'fs-extra'". Can you reproduce locally? |
I cleared the travis node modules cache and it didn't help |
I noticed my work on #33 would only copy first in the template directory, and explicitly had to check the src folder and copy it.
This instead just recursively copies the template folder into the root of the app.
Should work with deep nested paths like
./template/tests/components/myComponentTest.js
Though we don't necessarily need it now, if someone wants to add something to the template in the future, this is probably a better way to handle copying.