-
-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathconfig.js
53 lines (42 loc) · 1.18 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
const gitRepoInfo = require('git-repo-info');
const hostedGitInfo = require('hosted-git-info');
const semver = require('semver');
module.exports = class AddonDocsConfig {
constructor(project) {
this.project = project;
this.repoInfo = gitRepoInfo();
}
getPrimaryBranch() {
return 'main';
}
getRootURL() {
let repository = this.project.pkg.repository || '';
let info = hostedGitInfo.fromUrl(repository.url || repository);
return (info && info.project) || this.project.name();
}
getVersionPath() {
if ('ADDON_DOCS_VERSION_PATH' in process.env) {
return process.env.ADDON_DOCS_VERSION_PATH;
}
if (this.repoInfo.tag) {
return this.repoInfo.tag;
}
return this.repoInfo.branch || process.env.TRAVIS_BRANCH;
}
getVersionName() {
if ('ADDON_DOCS_VERSION_NAME' in process.env) {
return process.env.ADDON_DOCS_VERSION_NAME;
}
return this.getVersionPath();
}
shouldUpdateLatest() {
if ('ADDON_DOCS_UPDATE_LATEST' in process.env) {
return process.env.ADDON_DOCS_UPDATE_LATEST !== 'false';
}
let tag = this.repoInfo.tag;
if (tag) {
return !semver.prerelease(tag);
}
}
};