Fix gitcloud 0.2.3 import

This commit is contained in:
Ronan Jouchet 2021-06-14 14:39:43 -04:00
parent 9a6c6f870d
commit ea24a0fdeb
2 changed files with 19 additions and 16 deletions

View File

@ -55,7 +55,7 @@
"dependencies": {
"axios": "^0.21.1",
"electron-packager": "^15.2.0",
"gitcloud": "^0.2.0",
"gitcloud": "^0.2.3",
"hasbin": "^1.2.3",
"loglevel": "^1.7.1",
"ncp": "^2.0.0",
@ -68,21 +68,21 @@
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/ncp": "^2.0.4",
"@types/node": "^12.12.6",
"@types/node": "^12.20.15",
"@types/page-icon": "^0.3.3",
"@types/tmp": "^0.2.0",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"eslint": "^7.10.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^27.0.3",
"prettier": "^2.2.1",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.0.4",
"prettier": "^2.3.1",
"rimraf": "^3.0.2",
"ts-loader": "^9.2.1",
"typescript": "^4.2.3",
"webpack": "^5.24.4",
"webpack-cli": "^4.5.0"
"ts-loader": "^9.2.3",
"typescript": "^4.3.2",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.2"
},
"jest_COMMENTS": {
"testPathIgnorePatterns": "See https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring . We set it to 1. ignore coverage for deps, and 2. be sure we test the compiled JS, which is in `lib`, not `src` or `dist`",

View File

@ -2,7 +2,7 @@ import * as path from 'path';
import { writeFile } from 'fs';
import { promisify } from 'util';
import * as gitCloud from 'gitcloud';
import gitCloud = require('gitcloud');
import * as pageIcon from 'page-icon';
import {
@ -35,7 +35,10 @@ function getMatchingIcons(iconsWithScores: any[], maxScore: number): any[] {
.map((item) => ({ ...item, ext: path.extname(item.url) }));
}
function mapIconWithMatchScore(cloudIcons: any[], targetUrl: string): any {
function mapIconWithMatchScore(
cloudIcons: { name: string; url: string }[],
targetUrl: string,
): any {
const normalisedTargetUrl = targetUrl.toLowerCase();
return cloudIcons.map((item) => {
const itemWords = item.name.split(GITCLOUD_SPACE_DELIMITER);
@ -57,7 +60,7 @@ async function inferIconFromStore(
log.debug(`Inferring icon from store for ${targetUrl} on ${platform}`);
const allowedFormats = new Set(getAllowedIconFormats(platform));
const cloudIcons: any[] = await gitCloud(GITCLOUD_URL);
const cloudIcons = await gitCloud(GITCLOUD_URL);
log.debug(`Got ${cloudIcons.length} icons from gitcloud`);
const iconWithScores = mapIconWithMatchScore(cloudIcons, targetUrl);
const maxScore = getMaxMatchScore(iconWithScores);