mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 15:36:25 +00:00
Extract copystr function to lib/util/string.ts
This commit is contained in:
parent
fd3bf61046
commit
51ebf55c90
3 changed files with 12 additions and 17 deletions
|
@ -3,6 +3,7 @@ import { ExternalHostError } from '../../../types/errors/external-host-error';
|
|||
import { cache } from '../../../util/cache/package/decorator';
|
||||
import { getElapsedMinutes } from '../../../util/date';
|
||||
import { newlineRegex, regEx } from '../../../util/regex';
|
||||
import { copystr } from '../../../util/string';
|
||||
import * as perlVersioning from '../../versioning/perl';
|
||||
import { Datasource } from '../datasource';
|
||||
import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
|
||||
|
@ -57,13 +58,6 @@ export class CpanDatasource extends Datasource {
|
|||
return dep;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
||||
*/
|
||||
private static copystr(x: string): string {
|
||||
return (' ' + x).slice(1);
|
||||
}
|
||||
|
||||
async updateCpanVersions(): Promise<void> {
|
||||
const url = 'https://www.cpan.org/modules/02packages.details.txt';
|
||||
const options = {
|
||||
|
@ -109,7 +103,7 @@ export class CpanDatasource extends Datasource {
|
|||
}
|
||||
split = l.split(/\s+/);
|
||||
[pkg, latestVersion, path] = split;
|
||||
pkg = CpanDatasource.copystr(pkg);
|
||||
pkg = copystr(pkg);
|
||||
const distribution = path.replace(pathPattern, '$1');
|
||||
packages[pkg] = {
|
||||
release: {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { logger } from '../../../logger';
|
|||
import { ExternalHostError } from '../../../types/errors/external-host-error';
|
||||
import { getElapsedMinutes } from '../../../util/date';
|
||||
import { newlineRegex } from '../../../util/regex';
|
||||
import { copystr } from '../../../util/string';
|
||||
import { Datasource } from '../datasource';
|
||||
import type { GetReleasesConfig, ReleaseResult } from '../types';
|
||||
|
||||
|
@ -37,13 +38,6 @@ export class RubyGemsOrgDatasource extends Datasource {
|
|||
return dep;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
||||
*/
|
||||
private static copystr(x: string): string {
|
||||
return (' ' + x).slice(1);
|
||||
}
|
||||
|
||||
async updateRubyGemsVersions(): Promise<void> {
|
||||
const url = 'https://rubygems.org/versions';
|
||||
const options = {
|
||||
|
@ -88,7 +82,7 @@ export class RubyGemsOrgDatasource extends Datasource {
|
|||
}
|
||||
split = l.split(' ');
|
||||
[pkg, versions] = split;
|
||||
pkg = RubyGemsOrgDatasource.copystr(pkg);
|
||||
pkg = copystr(pkg);
|
||||
packageReleases[pkg] = packageReleases[pkg] || [];
|
||||
const lineVersions = versions.split(',').map((version) => version.trim());
|
||||
for (const lineVersion of lineVersions) {
|
||||
|
@ -99,7 +93,7 @@ export class RubyGemsOrgDatasource extends Datasource {
|
|||
(version) => version !== deletedVersion
|
||||
);
|
||||
} else {
|
||||
packageReleases[pkg].push(RubyGemsOrgDatasource.copystr(lineVersion));
|
||||
packageReleases[pkg].push(copystr(lineVersion));
|
||||
}
|
||||
}
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
|
|
|
@ -45,3 +45,10 @@ export function uniqueStrings(
|
|||
): boolean {
|
||||
return elements.indexOf(element) === index;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://bugs.chromium.org/p/v8/issues/detail?id=2869
|
||||
*/
|
||||
export function copystr(x: string): string {
|
||||
return (' ' + x).slice(1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue