Created
January 25, 2017 01:27
-
-
Save tracker1/d6ad53e3cd9f17515d920f9f863b2949 to your computer and use it in GitHub Desktop.
Node.js PreTest script
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
const path = require('path'); | |
const glob = require('glob'); | |
const base = path.resolve(__dirname, '../'); | |
const allScripts = glob.sync(path.join(__dirname, '../src') + '/**/*.js'); | |
const tests = allScripts.filter(s => (/\.test\.js$/).test(s)); | |
const scripts = allScripts.filter(s => !(/\.(test|disabled|unsafe)\./).test(s)); | |
const untested = scripts.filter(s => !tests.includes(s.replace(/\.js$/,'.test.js'))); | |
if (untested.length) { | |
console.error('\n\nThe following scripts do not have a test file.'); | |
untested | |
.map(s => path.resolve(s).replace(base, '').substr(1)) | |
.forEach(s => console.error(` ${s}`)); | |
process.nextTick(() => process.exit(1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment