From 27c65737212e2d7e687a5837bdfcae5d078b404a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Dec 2021 23:07:15 +0100 Subject: [PATCH] Bump website-scraper from 4.2.3 to 5.0.0 (#11) * 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 --- .eslintrc.yml | 1 + README.md | 10 +++++----- index.js | 6 +++--- package.json | 13 ++++++++----- test/existing-directory-plugin.test.js | 14 ++++++++------ 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index ab11baa..4bd3495 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,6 +1,7 @@ extends: "eslint:recommended" parserOptions: ecmaVersion: 8 + sourceType: module env: node: true es6: true diff --git a/README.md b/README.md index e928d27..ec7a3f6 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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() ] diff --git a/index.js b/index.js index 0cad00c..4ae332b 100644 --- a/index.js +++ b/index.js @@ -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) { @@ -22,4 +22,4 @@ class SaveResourceToExistingDirectoryPlugin { } } -module.exports = SaveResourceToExistingDirectoryPlugin; +export default SaveResourceToExistingDirectoryPlugin; diff --git a/package.json b/package.json index daa0e08..93715a4 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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" } } diff --git a/test/existing-directory-plugin.test.js b/test/existing-directory-plugin.test.js index 29b7a1a..4fa4e09 100644 --- a/test/existing-directory-plugin.test.js +++ b/test/existing-directory-plugin.test.js @@ -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)); @@ -18,4 +20,4 @@ describe('Existing Directory Plugin', () => { expect(fs.existsSync(filename)).to.eql(true); }); -}); \ No newline at end of file +});