mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[validate-next-docs] declare how github urls are determined
This commit is contained in:
parent
648786e532
commit
fe93e71412
1 changed files with 9 additions and 4 deletions
|
@ -24,13 +24,14 @@ function lines(read: NodeJS.ReadableStream) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGithubBase() {
|
function getGithubBase(log: ToolingLog) {
|
||||||
try {
|
try {
|
||||||
const originUrl = execa.sync('git', ['remote', 'get-url', 'origin'], {
|
const originUrl = execa.sync('git', ['remote', 'get-url', 'origin'], {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}).stdout;
|
}).stdout;
|
||||||
|
|
||||||
if (originUrl.startsWith('git@')) {
|
if (originUrl.startsWith('git@')) {
|
||||||
|
log.warning('using ssh urls for Github repos');
|
||||||
return `git@github.com:`;
|
return `git@github.com:`;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -38,9 +39,11 @@ function getGithubBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.GITHUB_TOKEN) {
|
if (process.env.GITHUB_TOKEN) {
|
||||||
return `https://${process.env.GITHUB_TOKEN}@github.com/`;
|
log.warning('using https urls for Github repos (with token)');
|
||||||
|
return `https://token:${process.env.GITHUB_TOKEN}@github.com/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.warning('using https urls for Github repos');
|
||||||
return `https://github.com/`;
|
return `https://github.com/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,10 +149,12 @@ export class Repo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Repos {
|
export class Repos {
|
||||||
githubBase = getGithubBase();
|
githubBase: string;
|
||||||
repoDir = Path.resolve(Os.userInfo().homedir, '.cache/next-docs/repos');
|
repoDir = Path.resolve(Os.userInfo().homedir, '.cache/next-docs/repos');
|
||||||
|
|
||||||
constructor(private readonly log: ToolingLog) {}
|
constructor(private readonly log: ToolingLog) {
|
||||||
|
this.githubBase = getGithubBase(this.log);
|
||||||
|
}
|
||||||
|
|
||||||
async init(repoName: string) {
|
async init(repoName: string) {
|
||||||
const repo = new Repo(
|
const repo = new Repo(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue