Fix .gitignore placement when running example script or docusaurus-init (#533)

Fixes #415
This commit is contained in:
Joel Marcey 2018-04-08 07:35:35 -07:00 committed by GitHub
parent 6500f9bacf
commit fc051acde5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View file

@ -1,11 +1,13 @@
node_modules
.DS_Store
node_modules
lib/core/metadata.js
lib/core/MetadataBlog.js
website/translated_docs
website/build/
website/yarn.lock
website/node_modules
website/i18n/*
!website/i18n/en.json

View file

@ -156,15 +156,20 @@ if (feature === 'translations') {
blogCreated = true;
}
// copy .gitignore file
if (fs.existsSync(CWD + '/.gitignore')) {
let gitignoreName = '.gitignore';
if (fs.existsSync(CWD + '/../.gitignore')) {
gitignoreName = '.gitignore-example-from-docusaurus';
console.log(
`${chalk.yellow('.gitignore already exists')} in ${chalk.yellow(
CWD
)}. Rename or remove the file to regenerate an example version.\n`
)}. Creating an example gitignore file for you to copy from if desired.\n`
);
} else {
fs.copySync(path.join(folder, 'gitignore'), path.join(CWD, '.gitignore'));
}
fs.copySync(
path.join(folder, 'gitignore'),
path.join(CWD, '/../' + gitignoreName)
);
// copy other files
let files = glob.sync(folder + '/**/*');
files.forEach(file => {