Copy files instead of moving them during init

This commit is contained in:
Christopher Chedeau
2016-07-18 11:47:48 -07:00
parent e515bbbc7d
commit 8989a08b68

View File

@@ -35,10 +35,18 @@ module.exports = function(hostPath, appName, verbose) {
JSON.stringify(hostPackage, null, 2)
);
// Move the files for the user
// TODO: copying might be more correct?
fs.renameSync(path.join(selfPath, 'src'), path.join(hostPath, 'src'));
fs.renameSync(path.join(selfPath, 'index.html'), path.join(hostPath, 'index.html'));
// 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, 'src')).forEach(function(filename) {
copySync(
path.join(selfPath, 'src', filename),
path.join(hostPath, 'src', filename)
);
});
copySync(path.join(selfPath, 'index.html'), path.join(hostPath, 'index.html'));
// Run another npm install for react and react-dom
// TODO: having to do two npm installs is bad, can we avoid it?