feat: add check for contributors

This commit is contained in:
Karl-Philipp Wulfert
2019-04-04 13:56:11 +02:00
parent 61d2285a1f
commit ab81aab046

View File

@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import chalk from 'chalk';
import {execSync} from 'child_process';
import * as commander from 'commander';
import {copyFileSync, existsSync, readFileSync, writeFileSync} from 'fs';
import {resolve, sep} from 'path';
@@ -168,6 +169,27 @@ Object.keys(SCRIPTS).forEach((scriptName) => {
}
});
const execBuffer = execSync('git log --format=\'%aN\' | sort -u');
for (let author of execBuffer.toString().split('\n')) {
author = author.trim();
if (author === '') {
continue;
}
let authorIsAttributed = false;
authorIsAttributed = authorIsAttributed
|| (typeof packageJson.author === 'string' && packageJson.author.indexOf(author) >= 0)
|| (Array.isArray(packageJson.contributors) && packageJson.contributors.find((contributor: string) => {
return contributor.indexOf(author) >= 0;
}));
if (!authorIsAttributed) {
consoleInfo(`'${author}' should be attributed as author or contributor.`);
}
}
// check CI config if it exists
const pathToCiConfig = resolve(path, '.gitlab-ci.yml');
if (existsSync(pathToCiConfig)) {