Skip to content

Commit

Permalink
Update npm dependencies (GHSA-vh7m-p724-62c2)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomontalbano committed Aug 4, 2020
1 parent cd53fef commit 36f12ba
Show file tree
Hide file tree
Showing 8 changed files with 1,183 additions and 1,709 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_js:
- "11"
- "12"
- "13"
- "14"

script:
- npm test
Expand Down
2 changes: 1 addition & 1 deletion docs/app.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/demo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const path = require('path');
const fs = require('fs');
const htmlMiner = require('../lib');
Expand Down
1 change: 0 additions & 1 deletion examples/site.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const url = require('url');
const https = require('https');
const htmlMiner = require('../lib');
Expand Down
2,788 changes: 1,094 additions & 1,694 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-miner",
"version": "3.0.0",
"version": "3.0.1",
"description": "A powerful miner that will scrape html pages for you. ` HTML Scraper ´",
"main": "index.js",
"repository": "https://github.com/marcomontalbano/html-miner.git",
Expand Down Expand Up @@ -37,21 +37,21 @@
},
"dependencies": {
"cheerio": "^0.22.0",
"lodash": "~4.17.15"
"lodash": "~4.17.19"
},
"devDependencies": {
"@babel/cli": "~7.8.4",
"@babel/core": "~7.9.0",
"@babel/preset-env": "~7.9.0",
"@babel/cli": "~7.10.5",
"@babel/core": "~7.11.0",
"@babel/preset-env": "~7.11.0",
"babel-eslint": "~10.1.0",
"babel-preset-minify": "~0.5.1",
"browserify": "~16.5.1",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "~14.1.0",
"eslint-plugin-import": "~2.20.2",
"mocha": "^7.1.1",
"nyc": "~15.0.1",
"eslint-config-airbnb-base": "~14.2.0",
"eslint-plugin-import": "~2.22.0",
"mocha": "^7.2.0",
"nyc": "~15.1.0",
"rest": "^2.0.0"
}
}
78 changes: 78 additions & 0 deletions test/example.md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const chai = require('chai');

const { assert } = chai;

const htmlMiner = require('../lib');

describe('htmlMiner • EXAMPLE.md', () => {
it('Get text and href from a list of <a>', () => {
const html = `
<div>
<a class="link-class" href="https://example.com/1">Link 1</a>
<a class="link-class" href="https://example.com/2">Link 2</a>
</div>
`;

const actual = htmlMiner(html, {
_each_: '.link-class',
text: (arg) => arg.$scope.text(),
href: (arg) => arg.$scope.attr('href'),
});

assert.deepEqual(actual, [
{
text: 'Link 1',
href: 'https://example.com/1',
},
{
text: 'Link 2',
href: 'https://example.com/2',
},
]);
});

describe('Get src and alt from <img>', () => {
const html = `
<img src="/image-1.jpg" alt="Image 1" />
<img src="/image-2.jpg" alt="Image 2" />
`;

const doAssert = (actual) => {
assert.deepEqual(actual, [
{
src: '/image-1.jpg',
alt: 'Image 1',
},
{
src: '/image-2.jpg',
alt: 'Image 2',
},
]);
};

it('Selector as function', () => {
const actual = htmlMiner(html, (arg) => {
const $images = Array.from(arg.$('img'));
return $images.map((img) => {
const $currentImage = arg.$(img);
return {
src: $currentImage.attr('src'),
alt: $currentImage.attr('alt'),
};
});
});

doAssert(actual);
});

it('Simpler way', () => {
const actual = htmlMiner(html, {
_each_: 'img',
src: (arg) => arg.$scope.attr('src'),
alt: (arg) => arg.$scope.attr('alt'),
});

doAssert(actual);
});
});
});
3 changes: 0 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const chai = require('chai');

const { assert } = chai;
Expand Down Expand Up @@ -49,7 +48,6 @@ describe('htmlMiner', () => {
});
});


//
describe('should returns an undefined', () => {
it('given an incorrect html (e.g. \'undefined\')', () => {
Expand Down Expand Up @@ -454,7 +452,6 @@ describe('htmlMiner', () => {
});
});


it('should work with complex combination', () => {
const actual = htmlMiner(html, {
title: 'h1',
Expand Down

0 comments on commit 36f12ba

Please sign in to comment.