Skip to content

Commit

Permalink
Fix .gitignore placement when running example script or docusaurus-in…
Browse files Browse the repository at this point in the history
…it (#533)

Fixes #415
  • Loading branch information
JoelMarcey committed Apr 8, 2018
1 parent 6500f9b commit fc051ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions examples/basics/gitignore
Original file line number Diff line number Diff line change
@@ -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
13 changes: 9 additions & 4 deletions lib/copy-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit fc051ac

Please sign in to comment.