Skip to content

Commit

Permalink
deps: fix deprecated import of cheerio
Browse files Browse the repository at this point in the history
  • Loading branch information
myfreeer committed Mar 3, 2024
1 parent bc06c9c commit 8742bb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/mdn/mdn-merge-samples.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Entry} from 'fast-glob';
import glob from 'fast-glob';
import cheerio from 'cheerio';
import {load} from 'cheerio';
import fs from 'fs';
import path from 'path';
import {mkdirRetry} from 'website-scrap-engine/lib/io';
Expand Down Expand Up @@ -126,7 +126,7 @@ const parseResourceAsync = async (item: MdnSampleItem): Promise<void> => {
delete item.pendingGetResources;
return;
} else {
parseResourceSync(item, cheerio.load(content));
parseResourceSync(item, load(content));
}
};

Expand Down Expand Up @@ -174,7 +174,7 @@ const checkIsEmpty = async (item: MdnSampleItem): Promise<void> => {
item.resources = [];
return;
}
const $: CheerioStatic = cheerio.load(content);
const $: CheerioStatic = load(content);
const body: Cheerio = $('body');
let html;
if (!body.length ||
Expand Down
10 changes: 5 additions & 5 deletions test/mdn/process-url/detect-link-type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {detectLinkType} from '../../../src/mdn/process-url/detect-link-type';
import type {Resource} from 'website-scrap-engine/lib/resource';
import {ResourceType} from 'website-scrap-engine/lib/resource';
import cheerio from 'cheerio';
import {load} from 'cheerio';
import URI = require('urijs');

describe('detect-link-type', function () {
test('html', () => {
const a = cheerio.load('<a></a>')('a');
const iframe = cheerio.load('<a></a>')('a');
const a = load('<a></a>')('a');
const iframe = load('<a></a>')('a');
expect(detectLinkType('https://developer.mozilla.org/zh-CN/docs/Web/API',
ResourceType.Css, a, null)).toBe(ResourceType.Html);
expect(detectLinkType('https://developer.mozilla.org/',
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('detect-link-type', function () {
ResourceType.Html, null, null)).toBe(ResourceType.Html);
});
test('binary', () => {
const a = cheerio.load('<a></a>')('a');
const a = load('<a></a>')('a');
expect(detectLinkType('https://developer.mozilla.org/@api/deki/files/3783/=codeanalyst4.PNG',
ResourceType.Html, a, null)).toBe(ResourceType.Binary);
expect(detectLinkType('https://developer.mozilla.org/files/15838/places-erd.png',
Expand All @@ -54,7 +54,7 @@ describe('detect-link-type', function () {
});
test('css', () => {

const a = cheerio.load('<a></a>')('a');
const a = load('<a></a>')('a');
expect(detectLinkType('https://developer.mozilla.org/ecosystem-platform/css/main.css',
ResourceType.Binary, a, null)).toBe(ResourceType.Css);
expect(detectLinkType('https://developer.mozilla.org/static/build/styles/samples.37902ba3b7fe.css',
Expand Down

0 comments on commit 8742bb8

Please sign in to comment.