electron/script/doc-only-change.js
Samuel Attard 8af5c6d130
build: update some build dependencies (#44069)
* build: update some build dependencies (#43882)

* build: update some build dependencies

* build: fix eslint issues after updating

* build: disable ts check on busted js example

* build: update internal types for stricter event handling

* restore url.parse behavior

* fix typing issues

* sigh

* build: update easy deps

* build: skip woa engines check

* build: s/colors/chalk
2024-10-01 11:09:28 -07:00

44 lines
1.3 KiB
JavaScript

const args = require('minimist')(process.argv.slice(2));
const { Octokit } = require('@octokit/rest');
const octokit = new Octokit();
async function checkIfDocOnlyChange () {
let { prNumber, prURL } = args;
if (prNumber || prURL) {
try {
// extract the PR number from the PR URL.
if (!prNumber || isNaN(prNumber)) {
if (args.prURL) {
prNumber = prURL.split('/').pop();
}
}
const filesChanged = await octokit.paginate(octokit.pulls.listFiles.endpoint.merge({
owner: 'electron',
repo: 'electron',
pull_number: prNumber,
per_page: 100
}));
console.log('Changed Files: ', filesChanged.map(fileInfo => fileInfo.filename));
const nonDocChange = filesChanged.length === 0 || filesChanged.find(({ filename }) => {
const fileDirs = filename.split('/');
if (fileDirs[0] !== 'docs') return true;
return false;
});
process.exit(nonDocChange ? 1 : 0);
} catch (error) {
console.error('Error getting list of files changed: ', error);
process.exit(-1);
}
} else {
console.error(`Check if only the docs were changed for a commit.
Usage: doc-only-change.js --prNumber=PR_NUMBER || --prURL=PR_URL`);
process.exit(-1);
}
}
checkIfDocOnlyChange();