Move pluralize method into "pure" helpers file (since we don't require vscode)

This commit is contained in:
shati-patel
2022-10-21 15:03:33 +01:00
parent 31ef6aef29
commit add5417a42
6 changed files with 13 additions and 18 deletions

View File

@@ -584,11 +584,3 @@ export async function* walkDirectory(dir: string): AsyncIterableIterator<string>
}
}
}
/**
* Pluralizes a word.
* Example: Returns "N repository" if N is one, "N repositories" otherwise.
*/
export function pluralize(numItems: number | undefined, singular: string, plural: string): string {
return numItems !== undefined ? `${numItems} ${numItems === 1 ? singular : plural}` : '';
}

View File

@@ -4,9 +4,8 @@ import { QueryHistoryConfig } from './config';
import { LocalQueryInfo } from './query-results';
import { buildRepoLabel, getRawQueryName, QueryHistoryInfo } from './query-history-info';
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
import { pluralize } from './helpers';
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
import { assertNever } from './pure/helpers-pure';
import { assertNever, pluralize } from './pure/helpers-pure';
interface InterpolateReplacements {
t: string; // Start time

View File

@@ -55,3 +55,11 @@ export function getErrorStack(e: any) {
export function asError(e: any): Error {
return e instanceof Error ? e : new Error(String(e));
}
/**
* Pluralizes a word.
* Example: Returns "N repository" if N is one, "N repositories" otherwise.
*/
export function pluralize(numItems: number | undefined, singular: string, plural: string): string {
return numItems !== undefined ? `${numItems} ${numItems === 1 ? singular : plural}` : '';
}

View File

@@ -1,8 +1,7 @@
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
import { LocalQueryInfo } from './query-results';
import { assertNever } from './pure/helpers-pure';
import { pluralize } from './helpers';
import { assertNever, pluralize } from './pure/helpers-pure';
import { hasRepoScanCompleted } from './remote-queries/shared/variant-analysis';
export type QueryHistoryInfo = LocalQueryInfo | RemoteQueryHistoryItem | VariantAnalysisHistoryItem;

View File

@@ -4,10 +4,7 @@ import * as fs from 'fs-extra';
import { window, commands, Uri, ExtensionContext, QuickPickItem, workspace, ViewColumn } from 'vscode';
import { Credentials } from '../authentication';
import { UserCancellationException } from '../commandRunner';
import {
showInformationMessageWithAction,
pluralize
} from '../helpers';
import { showInformationMessageWithAction } from '../helpers';
import { logger } from '../logging';
import { QueryHistoryManager } from '../query-history';
import { createGist } from './gh-api/gh-actions-api-client';
@@ -16,6 +13,7 @@ import { generateMarkdown } from './remote-queries-markdown-generation';
import { RemoteQuery } from './remote-query';
import { AnalysisResults, sumAnalysesResults } from './shared/analysis-result';
import { RemoteQueryHistoryItem } from './remote-query-history-item';
import { pluralize } from '../pure/helpers-pure';
/**
* Exports the results of the given or currently-selected remote query.

View File

@@ -11,7 +11,6 @@ import {
showAndLogErrorMessage,
showAndLogInformationMessage,
tryGetQueryMetadata,
pluralize,
tmpDir,
} from '../helpers';
import { Credentials } from '../authentication';
@@ -23,7 +22,7 @@ import { OctokitResponse, RequestError } from '@octokit/types/dist-types';
import { RemoteQuery } from './remote-query';
import { RemoteQuerySubmissionResult } from './remote-query-submission-result';
import { QueryMetadata } from '../pure/interface-types';
import { getErrorMessage, REPO_REGEX } from '../pure/helpers-pure';
import { getErrorMessage, REPO_REGEX, pluralize } from '../pure/helpers-pure';
import * as ghApiClient from './gh-api/gh-api-client';
import { getRepositorySelection, isValidSelection, RepositorySelection } from './repository-selection';
import { parseVariantAnalysisQueryLanguage, VariantAnalysisSubmission } from './shared/variant-analysis';