-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-disable no-console */ | ||
const chalk = require('chalk'); | ||
const fse = require('fs-extra'); | ||
const glob = require('glob-gitignore'); | ||
const path = require('path'); | ||
|
||
const passMessage = chalk.gray; | ||
const failMessage = chalk.whiteBright; | ||
|
||
async function run() { | ||
const workspaceRoot = path.resolve(__dirname, '..'); | ||
|
||
const eslintignoreContent = await fse.readFile(path.join(workspaceRoot, '.eslintignore'), { | ||
encoding: 'utf8', | ||
}); | ||
const eslintignore = eslintignoreContent.split(/\r?\n/).slice(0, -1); | ||
|
||
const filenames = glob.sync('**/*.json', { | ||
cwd: workspaceRoot, | ||
ignore: eslintignore, | ||
}); | ||
|
||
let passed = true; | ||
const checks = filenames.map(async filename => { | ||
const content = await fse.readFile(path.join(workspaceRoot, filename), { encoding: 'utf8' }); | ||
try { | ||
JSON.parse(content); | ||
console.log(passMessage(filename)); | ||
} catch (error) { | ||
passed = false; | ||
console.error(failMessage(`Error parsing ${filename}:\n\n${String(error)}`)); | ||
} | ||
}); | ||
|
||
await Promise.all(checks); | ||
if (passed === false) { | ||
throw new Error('At least one file did not pass. Check the console output'); | ||
} | ||
} | ||
|
||
run().catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters