forked from karma-runner/karma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-contributors.js
23 lines (18 loc) · 1000 Bytes
/
update-contributors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { execSync } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')
const { resolve } = require('path')
const prepare = async (pluginConfig, { logger }) => {
// Example output:
// 1042 Vojta Jina <[email protected]>
// 412 Friedel Ziegelmayer <[email protected]>
// 206 dignifiedquire <[email protected]>
// 139 johnjbarton <[email protected]>
const stdout = execSync('git log --pretty=short | git shortlog -nse', { encoding: 'utf8' })
const pkgPath = resolve(__dirname, '..', 'package.json')
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
// First line is already included as author field. Last line is dropped as it is an empty line.
pkg.contributors = stdout.split('\n').slice(1, -1).map((line) => line.replace(/^[\W\d]+/, ''))
writeFileSync(pkgPath, JSON.stringify(pkg, undefined, ' ') + '\n', 'utf8')
logger.info('Updated contributors list.')
}
module.exports = { prepare }