Skip to content

Commit

Permalink
Bump website-scraper from 4.2.3 to 5.0.0 (#11)
Browse files Browse the repository at this point in the history
* Bump website-scraper from 4.2.3 to 5.0.0
* Migrate from CommonJS to ESM

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ilya Antipenko <ilya@antipenko.pp.ua>
  • Loading branch information
dependabot[bot] and aivus authored Dec 29, 2021
1 parent 80d6821 commit 27c6573
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends: "eslint:recommended"
parserOptions:
ecmaVersion: 8
sourceType: module
env:
node: true
es6: true
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Plugin for [website-scraper](https://github.com/website-scraper/node-website-scr
Please keep in mind that saving to existing directory may overwrite your files. Be careful with it!

## Requirements
* nodejs version >= 14
* website-scraper version >= 4
* nodejs version >= 14.14
* website-scraper version >= 5

## Installation
```sh
Expand All @@ -20,10 +20,10 @@ npm install website-scraper website-scraper-existing-directory

## Usage
```javascript
const scrape = require('website-scraper');
const SaveToExistingDirectoryPlugin = require('website-scraper-existing-directory');
import scrape from 'website-scraper';
import SaveToExistingDirectoryPlugin from 'website-scraper-existing-directory';

scrape({
await scrape({
urls: ['http://example.com'],
directory: '/path/to/save',
plugins: [ new SaveToExistingDirectoryPlugin() ]
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const fs = require('fs-extra');
import path from 'path';
import fs from 'fs-extra';

class SaveResourceToExistingDirectoryPlugin {
apply (registerAction) {
Expand All @@ -22,4 +22,4 @@ class SaveResourceToExistingDirectoryPlugin {
}
}

module.exports = SaveResourceToExistingDirectoryPlugin;
export default SaveResourceToExistingDirectoryPlugin;
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "website-scraper-existing-directory",
"version": "0.1.0",
"version": "1.0.0",
"description": "Plugin for website-scraper which allows to save resources to existing directory",
"readmeFilename": "README.md",
"main": "index.js",
"type": "module",
"exports": {
".": "./index.js"
},
"scripts": {
"test": "c8 --all --reporter=text --reporter=lcov mocha --recursive",
"eslint": "eslint index.js"
Expand All @@ -29,15 +32,15 @@
"chai": "^4.2.0",
"eslint": "^8.5.0",
"mocha": "^9.1.3",
"website-scraper": "^4.0.0"
"website-scraper": "^5.0.0"
},
"peerDependencies": {
"website-scraper": "^4.0.0"
"website-scraper": "^5.0.0"
},
"files": [
"index.js"
],
"engines": {
"node": ">=14"
"node": ">=14.14"
}
}
14 changes: 8 additions & 6 deletions test/existing-directory-plugin.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { expect } = require('chai');
const scrape = require('website-scraper');
const fs = require('fs-extra');
const ExistingDirectoryPlugin = require('../index');
import chai from 'chai';
import scrape from 'website-scraper';
import fs from 'fs-extra';
import ExistingDirectoryPlugin from '../index.js';

const { expect } = chai;

describe('Existing Directory Plugin', () => {
const directory = __dirname + '/directory-for-test';
const directory = './test/directory-for-test';
const filename = directory + '/index.html';

after('remove saved index.html from test directory', () => fs.removeSync(filename));
Expand All @@ -18,4 +20,4 @@ describe('Existing Directory Plugin', () => {

expect(fs.existsSync(filename)).to.eql(true);
});
});
});

0 comments on commit 27c6573

Please sign in to comment.