Skip to content

Commit 90964b9

Browse files
committed
Bump version of rimraf to latest version
The update also adds an example that uses the `resetCache` flag.
1 parent 1ba2f21 commit 90964b9

File tree

4 files changed

+708
-116
lines changed

4 files changed

+708
-116
lines changed

examples/example-reset.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Usage example.
3+
*
4+
* Run with `node example.js`. This should report some progress info to the
5+
* console and save files in the "cache" folder
6+
*/
7+
const fetch = require('../');
8+
9+
// URLs to crawl, some of which may be identical
10+
// The API
11+
let urls = [
12+
'https://api.github.com/users/tidoust',
13+
'https://api.github.com/repos/tidoust/fetch-filecache-for-crawling/issues',
14+
'https://api.github.com/users/tidoust',
15+
'https://api.github.com/repos/tidoust/fetch-filecache-for-crawling/issues'
16+
]
17+
18+
fetch.setParameter('logToConsole', true);
19+
fetch.setParameter('resetCache', true);
20+
async function run() {
21+
for (const url of urls) {
22+
const response = await fetch(url);
23+
const json = await response.json();
24+
console.log('Got some JSON');
25+
}
26+
}
27+
run().catch(err => console.error(err));

fetch-filecache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const crypto = require('crypto');
99
const URL = require('url');
1010
const filenamifyUrl = require('filenamify-url');
11-
const rimraf = require('rimraf');
11+
const { rimraf } = require('rimraf');
1212
const path = require('path');
1313
const fs = require('fs');
1414

@@ -201,7 +201,7 @@ async function cacheFetch(url, options) {
201201

202202
if (config.resetCache && !cacheFolderReset[config.cacheFolder]) {
203203
cacheFolderReset[config.cacheFolder] = true;
204-
await rimraf(config.cacheFolder + '/*');
204+
await rimraf(config.cacheFolder + '/*', { glob: true });
205205
}
206206

207207
function log(msg) {

0 commit comments

Comments
 (0)