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

Commit 8989a08

Browse files
committed
Copy files instead of moving them during init
1 parent e515bbb commit 8989a08

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

scripts/init.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ module.exports = function(hostPath, appName, verbose) {
3535
JSON.stringify(hostPackage, null, 2)
3636
);
3737

38-
// Move the files for the user
39-
// TODO: copying might be more correct?
40-
fs.renameSync(path.join(selfPath, 'src'), path.join(hostPath, 'src'));
41-
fs.renameSync(path.join(selfPath, 'index.html'), path.join(hostPath, 'index.html'));
38+
// Copy the files for the user
39+
function copySync(src, dest) {
40+
return fs.writeFileSync(dest, fs.readFileSync(src));
41+
}
42+
fs.mkdirSync(path.join(hostPath, 'src'));
43+
fs.readdirSync(path.join(selfPath, 'src')).forEach(function(filename) {
44+
copySync(
45+
path.join(selfPath, 'src', filename),
46+
path.join(hostPath, 'src', filename)
47+
);
48+
});
49+
copySync(path.join(selfPath, 'index.html'), path.join(hostPath, 'index.html'));
4250

4351
// Run another npm install for react and react-dom
4452
// TODO: having to do two npm installs is bad, can we avoid it?

0 commit comments

Comments
 (0)