mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
nits & better console.log
This commit is contained in:
parent
a1a26d1c2e
commit
87bd1bea05
2 changed files with 31 additions and 33 deletions
|
@ -124,11 +124,9 @@ if (feature === 'translations') {
|
|||
// copy docs examples
|
||||
if (fs.existsSync(`${CWD}/../docs-examples-from-docusaurus`)) {
|
||||
console.log(
|
||||
`${chalk.yellow(
|
||||
'Example docs already exist!'
|
||||
)} Rename or remove ${chalk.yellow(
|
||||
`${outerFolder}/docs-examples-from-docusaurus`
|
||||
)} to regenerate example docs.\n`
|
||||
`- ${chalk.green(
|
||||
'docs-examples-from-docusaurus'
|
||||
)} already exists in ${chalk.blue(outerFolder)}.`
|
||||
);
|
||||
} else {
|
||||
fs.copySync(
|
||||
|
@ -141,11 +139,9 @@ if (feature === 'translations') {
|
|||
// copy blog examples
|
||||
if (fs.existsSync(`${CWD}/blog-examples-from-docusaurus`)) {
|
||||
console.log(
|
||||
`${chalk.yellow(
|
||||
'Example blog posts already exist!'
|
||||
)} Rename or remove ${chalk.yellow(
|
||||
`${outerFolder}/website/blog-examples-from-docusaurus`
|
||||
)} to regenerate example blog posts.\n`
|
||||
`- ${chalk.green(
|
||||
'blog-examples-from-docusaurus'
|
||||
)} already exists in ${chalk.blue(`${outerFolder}/website`)}.`
|
||||
);
|
||||
} else {
|
||||
fs.copySync(
|
||||
|
@ -156,33 +152,32 @@ if (feature === 'translations') {
|
|||
blogCreated = true;
|
||||
}
|
||||
|
||||
const copyFileOutWebsiteFolder = (fileNameFrom, isHide) => {
|
||||
let fileNameTo = isHide ? `.${fileNameFrom}` : fileNameFrom;
|
||||
if (fs.existsSync(`${CWD}/../${fileNameTo}`)) {
|
||||
fileNameTo = `${fileNameTo}-example-from-docusaurus`;
|
||||
const copyFileToWebsite = (fileNameFrom, fileNameTo) => {
|
||||
const copiedFileName = fileNameTo || fileNameFrom;
|
||||
const src = path.join(folder, fileNameFrom);
|
||||
const dest = path.join(CWD, '..', copiedFileName);
|
||||
if (fs.existsSync(dest)) {
|
||||
console.log(
|
||||
`${chalk.yellow(fileNameTo + ' already exists')} in ${chalk.yellow(
|
||||
CWD
|
||||
)}. Creating an example ${fileNameTo} file for you to copy from if desired.\n`
|
||||
`- ${chalk.green(copiedFileName)} already exists in ${chalk.blue(
|
||||
outerFolder
|
||||
)}.`
|
||||
);
|
||||
} else {
|
||||
fs.copySync(src, dest);
|
||||
}
|
||||
fs.copySync(
|
||||
path.join(folder, fileNameFrom),
|
||||
path.join(CWD, `/../${fileNameTo}`)
|
||||
);
|
||||
};
|
||||
|
||||
// copy .gitignore file
|
||||
copyFileOutWebsiteFolder('gitignore', true);
|
||||
copyFileToWebsite('gitignore', '.gitignore');
|
||||
|
||||
// copy Dockerfile file
|
||||
copyFileOutWebsiteFolder('Dockerfile', false);
|
||||
copyFileToWebsite('Dockerfile');
|
||||
|
||||
// copy docker-compose.yml file
|
||||
copyFileOutWebsiteFolder('docker-compose.yml', false);
|
||||
copyFileToWebsite('docker-compose.yml');
|
||||
|
||||
// copy .dockerignore file
|
||||
copyFileOutWebsiteFolder('dockerignore', true);
|
||||
copyFileToWebsite('dockerignore', '.dockerignore');
|
||||
|
||||
// copy other files
|
||||
const files = glob.sync(`${folder}/**/*`);
|
||||
|
@ -210,11 +205,11 @@ if (feature === 'translations') {
|
|||
exampleSiteCreated = true;
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`${chalk.yellow(
|
||||
`${path.basename(filePath)} already exists`
|
||||
)} in ${chalk.yellow(
|
||||
`website${filePath.split(path.basename(filePath))[0]}`
|
||||
)}. Rename or remove the file to regenerate an example version.\n`
|
||||
`- ${chalk.green(
|
||||
`${path.basename(filePath)}`
|
||||
)} already exists in ${chalk.blue(
|
||||
`${outerFolder}/website${filePath.split(path.basename(filePath))[0]}`
|
||||
)}.`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue