<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. --> - [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md). - [x] My pull request has a descriptive title (not a vague title like `Update index.md`) - [x] My pull request targets the `master` branch of freeCodeCamp. Closes #34535
		
			
				
	
	
		
			35 lines
		
	
	
		
			902 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			902 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const readdirp = require('readdirp-walk');
 | |
| const { has } = require('lodash');
 | |
| const ora = require('ora');
 | |
| 
 | |
| const {
 | |
|   guideRoot,
 | |
|   checkGuideFile,
 | |
|   checkFrontmatter,
 | |
|   extractLangFromFileName
 | |
| } = require('./md-testing-utils');
 | |
| 
 | |
| const spinner = ora('Checking guide markdown formatting').start();
 | |
| 
 | |
| const guideFrontmatterValidator = file => frontmatter => {
 | |
|   const hasLocale =
 | |
|     extractLangFromFileName(file) === 'english'
 | |
|       ? true
 | |
|       : has(frontmatter, 'localeTitle');
 | |
|   const hasTitle = has(frontmatter, 'title');
 | |
|   return hasLocale && hasTitle;
 | |
| };
 | |
| 
 | |
| readdirp({ root: guideRoot })
 | |
|   .on('data', file =>
 | |
|     Promise.all([
 | |
|       checkGuideFile(file),
 | |
|       checkFrontmatter(file, { validator: guideFrontmatterValidator(file) })
 | |
|     ]).catch(err => {
 | |
|       console.error(err);
 | |
|       // eslint-disable-next-line no-process-exit
 | |
|       process.exit(1);
 | |
|     })
 | |
|   )
 | |
|   .on('end', () => spinner.stop());
 |