Skip to content

Commit

Permalink
[CodeFactor] Apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
code-factor committed Jan 20, 2023
1 parent b8f2aaf commit cfdd892
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class Downloader {
if (json.error) {
throw json.error
}
return await renderArticle(json, articleId, dump, this.mwCapabilities)
return renderArticle(json, articleId, dump, this.mwCapabilities)
}

public async getJSON<T>(_url: string): Promise<T> {
Expand Down Expand Up @@ -532,7 +532,7 @@ class Downloader {
.buffer(resp.data, imageminOptions.get('webp').get(resp.headers['content-type']))
.catch(async (err) => {
if (/Unsupported color conversion request/.test(err.stderr)) {
return await (imagemin as any)
return (imagemin as any)
.buffer(await sharp(resp.data).toColorspace('srgb').toBuffer(), imageminOptions.get('webp').get(resp.headers['content-type']))
.catch(() => {
return resp.data
Expand All @@ -542,7 +542,7 @@ class Downloader {
return data
})
} else {
return await (imagemin as any).buffer(resp.data, imageminOptions.get('default').get(resp.headers['content-type'])).catch(() => {
return (imagemin as any).buffer(resp.data, imageminOptions.get('default').get(resp.headers['content-type'])).catch(() => {
return resp.data
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/mwoffliner.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ async function execute(argv: any) {
logger.log('Downloading module dependencies')
await Promise.all(
allDependenciesWithType.map(async ({ type, moduleList }) => {
return await pmap(
return pmap(
moduleList,
(oneModule) => {
return downloadAndSaveModule(zimCreator, mw, downloader, dump, oneModule, type as any)
Expand Down Expand Up @@ -535,7 +535,7 @@ async function execute(argv: any) {
}

if (customZimFavicon) {
return await saveFavicon(zimCreator, customZimFavicon)
return saveFavicon(zimCreator, customZimFavicon)
}
const body = await downloader.getJSON<any>(mw.siteInfoUrl())
const entries = body.query.general
Expand All @@ -550,7 +550,7 @@ async function execute(argv: any) {
const logoUrl = parsedUrl.protocol ? entries.logo : 'http:' + entries.logo
const logoContent = await downloader.downloadContent(logoUrl)
await writeFilePromise(faviconPath, logoContent.content, null)
return await saveFavicon(zimCreator, faviconPath)
return saveFavicon(zimCreator, faviconPath)
}

async function readFileOrUrlByLine(resourcePath: string): Promise<string[]> {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/webpAndRedirection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Real-time computer graphics`
})

async function isWebpPresent(path: string, zimFile: ZimReader) {
return await zimFile
return zimFile
.getArticleByUrl(path)
.then(async (result) => {
return (await FileType.fileTypeFromBuffer(result.data))?.mime === 'image/webp'
Expand All @@ -71,7 +71,7 @@ async function isWebpPresent(path: string, zimFile: ZimReader) {
}

async function isRedirectionPresent(path: string, zimFile: ZimReader) {
return await zimFile.getArticleByUrl('A/Animation').then((result) => {
return zimFile.getArticleByUrl('A/Animation').then((result) => {
return result.data.toString().includes(path)
})
}

0 comments on commit cfdd892

Please sign in to comment.