2019-08-30 20:14:53 +02:00
|
|
|
const sh = require('shelljs');
|
|
|
|
const path = require('path');
|
2017-01-04 17:58:54 +02:00
|
|
|
|
2019-08-30 20:14:53 +02:00
|
|
|
module.exports = function(commit, commitRange) {
|
2017-01-04 17:58:54 +02:00
|
|
|
const SINGLE_COMMIT = `git diff-tree --no-commit-id --name-only -r ${commit}`;
|
|
|
|
const COMMIT_RANGE = `git diff --name-only ${commitRange}`;
|
|
|
|
|
|
|
|
let command = SINGLE_COMMIT;
|
|
|
|
|
|
|
|
if (commitRange) {
|
2019-08-30 20:14:53 +02:00
|
|
|
command = COMMIT_RANGE;
|
2017-01-04 17:58:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const output = sh.exec(command, {async: false, silent: true}).stdout;
|
|
|
|
|
|
|
|
const files = output.split('\n').filter(Boolean);
|
2019-08-30 20:14:53 +02:00
|
|
|
|
2017-01-04 17:58:54 +02:00
|
|
|
return files.every((file) => file.startsWith('docs') || path.extname(file) === '.md');
|
|
|
|
};
|