UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

55 lines 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.editFileInRepoUrl = editFileInRepoUrl; exports.viewFileInRepoUrl = viewFileInRepoUrl; const posix_1 = require("./posix"); /** * * @param repoConfig * @param repoConfig.url * @param repoConfig.mainBranch * @param filePath * @param repoConfig.platform * @param scope * @param lineNumber */ function editFileInRepoUrl({ url, mainBranch, platform = 'github' }, filePath, scope, lineNumber) { if (url && mainBranch) { const rUrl = url.replace(/\/$/, ''); const fPath = (0, posix_1.posix)(filePath).replace(/^\//, ''); let editUrl = ''; if (platform === 'github') { editUrl = `${rUrl}/edit/${mainBranch}/${fPath}?message=docs(${scope}): describe your changes here...${lineNumber ? `#L${lineNumber}` : ''}`; } else if (platform === 'gitlab') { editUrl = `${rUrl}/-/edit/${mainBranch}/${fPath}?message=docs(${scope}): describe your changes here...${lineNumber ? `#L${lineNumber}` : ''}`; } return editUrl; } return filePath; } /** * * @param repoConfig * @param repoConfig.url * @param repoConfig.releaseBranch * @param filePath * @param repoConfig.platform * @param lineNumber */ function viewFileInRepoUrl({ url, releaseBranch, platform = 'github' }, filePath, lineNumber) { if (url && releaseBranch) { const rUrl = url.replace(/\/$/, ''); const fPath = (0, posix_1.posix)(filePath).replace(/^\//, ''); let viewUrl = ''; if (platform === 'github') { viewUrl = `${rUrl}/blob/${releaseBranch}/${fPath}${lineNumber ? `#L${lineNumber}` : ''}`; } else if (platform === 'gitlab') { viewUrl = `${rUrl}/-/blob/${releaseBranch}/${fPath}${lineNumber ? `#L${lineNumber}` : ''}`; } return viewUrl; } return filePath; } //# sourceMappingURL=repo-link.js.map