ESLintify Part 3 (#846)

* ESLintify Part 3

* ESLintify Part 3

* ESLintify Part 3
This commit is contained in:
Yangshun Tay 2018-07-11 03:21:31 -07:00 committed by Endilie Yacop Sucipto
parent 5ac2cee658
commit a7a214fb3a
54 changed files with 435 additions and 497 deletions

View file

@ -25,9 +25,9 @@ commander
.parse(process.argv);
// add scripts to package.json file
if (fs.existsSync(CWD + '/package.json')) {
if (fs.existsSync(`${CWD}/package.json`)) {
const packageContent = JSON.parse(
fs.readFileSync(CWD + '/package.json', 'utf8')
fs.readFileSync(`${CWD}/package.json`, 'utf8')
);
if (!packageContent.scripts) {
packageContent.scripts = {};
@ -41,8 +41,8 @@ if (fs.existsSync(CWD + '/package.json')) {
packageContent.scripts.version = 'docusaurus-version';
packageContent.scripts['rename-version'] = 'docusaurus-rename-version';
fs.writeFileSync(
CWD + '/package.json',
JSON.stringify(packageContent, null, 2) + '\n'
`${CWD}/package.json`,
`${JSON.stringify(packageContent, null, 2)}\n`
);
console.log(
`${chalk.green('Wrote docusaurus scripts to package.json file.')}\n`
@ -59,17 +59,17 @@ let exampleSiteCreated = false;
if (feature === 'translations') {
// copy files for translations
const folder = path.join(__dirname, '..', 'examples', 'translations');
if (fs.existsSync(CWD + '/../crowdin.yaml')) {
if (fs.existsSync(`${CWD}/../crowdin.yaml`)) {
console.log(
`${chalk.yellow('crowdin.yaml already exists')} in ${chalk.yellow(
outerFolder + '/'
`${outerFolder}/`
)}. Rename or remove the file to regenerate an example version.\n`
);
} else {
fs.copySync(folder + '/crowdin.yaml', CWD + '/../crowdin.yaml');
fs.copySync(`${folder}/crowdin.yaml`, `${CWD}/../crowdin.yaml`);
exampleSiteCreated = true;
}
const files = glob.sync(folder + '/**/*');
const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
@ -87,9 +87,9 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
path.basename(filePath) + ' already exists'
`${path.basename(filePath)} already exists`
)} in ${chalk.yellow(
'website' + filePath.split(path.basename(filePath))[0]
`website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n`
);
}
@ -97,7 +97,7 @@ if (feature === 'translations') {
} else if (feature === 'versions') {
// copy files for versions
const folder = path.join(__dirname, '..', 'examples', 'versions');
const files = glob.sync(folder + '/**/*');
const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
@ -112,9 +112,9 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
path.basename(filePath) + ' already exists'
`${path.basename(filePath)} already exists`
)} in ${chalk.yellow(
'website' + filePath.split(path.basename(filePath))[0]
`website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n`
);
}
@ -122,29 +122,29 @@ if (feature === 'translations') {
} else {
const folder = path.join(__dirname, '..', 'examples', 'basics');
// copy docs examples
if (fs.existsSync(CWD + '/../docs-examples-from-docusaurus')) {
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'
`${outerFolder}/docs-examples-from-docusaurus`
)} to regenerate example docs.\n`
);
} else {
fs.copySync(
folder + '/docs-examples-from-docusaurus',
CWD + '/../docs-examples-from-docusaurus'
`${folder}/docs-examples-from-docusaurus`,
`${CWD}/../docs-examples-from-docusaurus`
);
exampleSiteCreated = true;
docsCreated = true;
}
// copy blog examples
if (fs.existsSync(CWD + '/blog-examples-from-docusaurus')) {
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'
`${outerFolder}/website/blog-examples-from-docusaurus`
)} to regenerate example blog posts.\n`
);
} else {
@ -157,7 +157,7 @@ if (feature === 'translations') {
}
// copy .gitignore file
let gitignoreName = '.gitignore';
if (fs.existsSync(CWD + '/../.gitignore')) {
if (fs.existsSync(`${CWD}/../.gitignore`)) {
gitignoreName = '.gitignore-example-from-docusaurus';
console.log(
`${chalk.yellow('.gitignore already exists')} in ${chalk.yellow(
@ -167,11 +167,11 @@ if (feature === 'translations') {
}
fs.copySync(
path.join(folder, 'gitignore'),
path.join(CWD, '/../' + gitignoreName)
path.join(CWD, `/../${gitignoreName}`)
);
// copy other files
const files = glob.sync(folder + '/**/*');
const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
@ -194,9 +194,9 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
path.basename(filePath) + ' already exists'
`${path.basename(filePath)} already exists`
)} in ${chalk.yellow(
'website' + filePath.split(path.basename(filePath))[0]
`website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n`
);
}
@ -221,9 +221,9 @@ if (feature === 'translations') {
if (docsCreated) {
console.log(
`Rename ${chalk.yellow(
outerFolder + '/docs-examples-from-docusaurus'
`${outerFolder}/docs-examples-from-docusaurus`
)} to ${chalk.yellow(
outerFolder + '/docs'
`${outerFolder}/docs`
)} to see the example docs on your site.\n`
);
}
@ -231,9 +231,9 @@ if (docsCreated) {
if (blogCreated) {
console.log(
`Rename ${chalk.yellow(
outerFolder + '/website/blog-examples-from-docusaurus'
`${outerFolder}/website/blog-examples-from-docusaurus`
)} to ${chalk.yellow(
outerFolder + '/website/blog'
`${outerFolder}/website/blog`
)} to see the example blog posts on your site.\n`
);
}