/*** @license* Copyright Google LLC All Rights Reserved.** Use of this source code is governed by an MIT-style license that can be* found in the LICENSE file at https://angular.io/license*/const https = require('https');const shell = require('shelljs');function httpGet(server, path, headers) {return new Promise((resolve, reject) => {const options = {hostname: server,port: 443,path: path,method: 'GET',headers: {'User-Agent': 'script', ...headers}};https.get(options,(res) => {let json = '';res.on('data', (chunk) => json += chunk.toString());res.on('end', () => resolve(json));}).on('error', (e) => reject(e));});}let warnNoToken = true;async function githubGet(path) {const token = process.env['TOKEN'];const headers = {};if (token) {headers.Authorization = 'token ' + token;} else if (warnNoToken) {warnNoToken = false;console.warn('############################################################');console.warn('############################################################');console.warn('WARNING: you should set the TOKEN variable to a github token');console.warn('############################################################');console.warn('############################################################');}return JSON.parse(await httpGet('api.github.com', '/repos/angular/angular/' + path, headers));}async function githubPrInfo(prNumber) {const pr = (await githubGet('pulls/' + prNumber));const label = pr.head.label.split(':');const user = label[0];const branch = label[1];return {commits: pr.commits,repository: {user: user,gitUrl: `git@github.com:${user}/angular.git`,},branch: branch};}function gitHasLocalModifications() {return execNoFatal('git diff-index --quiet HEAD --').code != 0;}function execNoFatal(cmd, options) {const fatal = shell.config.fatal;try {shell.config.fatal = false;return shell.exec(cmd, options);} finally {shell.config.fatal = fatal;}}function getCurrentBranch() {return shell.exec('git branch', {silent: true}).stdout.toString().split('\n') // Break into lines.map((v) => v.trim()) // trim.filter((b) => b[0] == '*') // select current branch.map((b) => b.split('')[1])[0]; // remove leading `*`}exports.httpGet = httpGet;exports.githubGet = githubGet;exports.githubPrInfo = githubPrInfo;exports.gitHasLocalModifications = gitHasLocalModifications;exports.execNoFatal = execNoFatal;exports.getCurrentBranch = getCurrentBranch;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。