提交 918b0263 编写于 作者: T Tomas Vik

refactor: es modules exports for openers.ts

Use export keyword instead of specifying all the exports at the end of
file (CommonJS)
上级 349ea924
...@@ -9,7 +9,7 @@ import { createGitService } from './service_factory'; ...@@ -9,7 +9,7 @@ import { createGitService } from './service_factory';
import { handleError } from './log'; import { handleError } from './log';
import { VS_COMMANDS } from './command_names'; import { VS_COMMANDS } from './command_names';
const openUrl = (url: string) => export const openUrl = (url: string) =>
vscode.commands.executeCommand(VS_COMMANDS.OPEN, vscode.Uri.parse(url)); vscode.commands.executeCommand(VS_COMMANDS.OPEN, vscode.Uri.parse(url));
/** /**
...@@ -36,12 +36,12 @@ async function openLink(linkTemplate: string, workspaceFolder: string) { ...@@ -36,12 +36,12 @@ async function openLink(linkTemplate: string, workspaceFolder: string) {
await openUrl(await getLink(linkTemplate, workspaceFolder)); await openUrl(await getLink(linkTemplate, workspaceFolder));
} }
async function showIssues() { export async function showIssues() {
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
await openLink('$projectUrl/issues?assignee_id=$userId', workspaceFolder!); await openLink('$projectUrl/issues?assignee_id=$userId', workspaceFolder!);
} }
async function showMergeRequests() { export async function showMergeRequests() {
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
await openLink('$projectUrl/merge_requests?assignee_id=$userId', workspaceFolder!); await openLink('$projectUrl/merge_requests?assignee_id=$userId', workspaceFolder!);
} }
...@@ -89,11 +89,11 @@ async function getActiveFile() { ...@@ -89,11 +89,11 @@ async function getActiveFile() {
return `${fileUrl}${anchor}`; return `${fileUrl}${anchor}`;
} }
async function openActiveFile() { export async function openActiveFile() {
await openUrl((await getActiveFile())!); await openUrl((await getActiveFile())!);
} }
async function copyLinkToActiveFile() { export async function copyLinkToActiveFile() {
const fileUrl = await getActiveFile(); const fileUrl = await getActiveFile();
if (fileUrl) { if (fileUrl) {
...@@ -101,7 +101,7 @@ async function copyLinkToActiveFile() { ...@@ -101,7 +101,7 @@ async function copyLinkToActiveFile() {
} }
} }
async function openCurrentMergeRequest() { export async function openCurrentMergeRequest() {
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
const mr = await gitLabService.fetchOpenMergeRequestForCurrentBranch(workspaceFolder!); const mr = await gitLabService.fetchOpenMergeRequestForCurrentBranch(workspaceFolder!);
...@@ -110,12 +110,12 @@ async function openCurrentMergeRequest() { ...@@ -110,12 +110,12 @@ async function openCurrentMergeRequest() {
} }
} }
async function openCreateNewIssue() { export async function openCreateNewIssue() {
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
openLink('$projectUrl/issues/new', workspaceFolder!); openLink('$projectUrl/issues/new', workspaceFolder!);
} }
async function openCreateNewMr() { export async function openCreateNewMr() {
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
const project = await gitLabService.fetchCurrentProject(workspaceFolder!); const project = await gitLabService.fetchCurrentProject(workspaceFolder!);
const branchName = await createGitService(workspaceFolder!).fetchTrackingBranchName(); const branchName = await createGitService(workspaceFolder!).fetchTrackingBranchName();
...@@ -123,12 +123,12 @@ async function openCreateNewMr() { ...@@ -123,12 +123,12 @@ async function openCreateNewMr() {
openUrl(`${project!.webUrl}/merge_requests/new?merge_request%5Bsource_branch%5D=${branchName}`); openUrl(`${project!.webUrl}/merge_requests/new?merge_request%5Bsource_branch%5D=${branchName}`);
} }
async function openProjectPage() { export async function openProjectPage() {
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
openLink('$projectUrl', workspaceFolder!); openLink('$projectUrl', workspaceFolder!);
} }
async function openCurrentPipeline(workspaceFolder: string) { export async function openCurrentPipeline(workspaceFolder: string) {
const { pipeline } = await gitLabService.fetchPipelineAndMrForCurrentBranch(workspaceFolder); const { pipeline } = await gitLabService.fetchPipelineAndMrForCurrentBranch(workspaceFolder);
if (pipeline) { if (pipeline) {
...@@ -136,7 +136,7 @@ async function openCurrentPipeline(workspaceFolder: string) { ...@@ -136,7 +136,7 @@ async function openCurrentPipeline(workspaceFolder: string) {
} }
} }
async function compareCurrentBranch() { export async function compareCurrentBranch() {
let project = null; let project = null;
let lastCommitId = null; let lastCommitId = null;
const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne(); const workspaceFolder = await getCurrentWorkspaceFolderOrSelectOne();
...@@ -148,15 +148,3 @@ async function compareCurrentBranch() { ...@@ -148,15 +148,3 @@ async function compareCurrentBranch() {
openUrl(`${project.webUrl}/compare/master...${lastCommitId}`); openUrl(`${project.webUrl}/compare/master...${lastCommitId}`);
} }
} }
exports.openUrl = openUrl;
exports.showIssues = showIssues;
exports.showMergeRequests = showMergeRequests;
exports.openActiveFile = openActiveFile;
exports.copyLinkToActiveFile = copyLinkToActiveFile;
exports.openCurrentMergeRequest = openCurrentMergeRequest;
exports.openCreateNewIssue = openCreateNewIssue;
exports.openCreateNewMr = openCreateNewMr;
exports.openProjectPage = openProjectPage;
exports.openCurrentPipeline = openCurrentPipeline;
exports.compareCurrentBranch = compareCurrentBranch;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册