@tryghost/mg-fs-utils 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/FileCache.js +9 -5
- package/package.json +1 -2
package/lib/FileCache.js
CHANGED
|
@@ -3,7 +3,6 @@ import {URL} from 'node:url';
|
|
|
3
3
|
import {tmpdir} from 'node:os';
|
|
4
4
|
import {createHash} from 'node:crypto';
|
|
5
5
|
import * as dotenv from 'dotenv';
|
|
6
|
-
import _ from 'lodash';
|
|
7
6
|
import {writeFileSync, readdirSync, rmSync, lstatSync, existsSync} from 'node:fs';
|
|
8
7
|
import {writeFile} from 'node:fs/promises';
|
|
9
8
|
import {outputJson, outputJsonSync, mkdirpSync, readJson, remove, outputFile} from 'fs-extra/esm';
|
|
@@ -232,7 +231,7 @@ export default class FileCache {
|
|
|
232
231
|
}
|
|
233
232
|
|
|
234
233
|
// @TODO: use content type on request to infer this, rather than assuming jpeg?
|
|
235
|
-
if (type === 'images' && !
|
|
234
|
+
if (type === 'images' && !knownImageExtensions.includes(ext)) {
|
|
236
235
|
if (!ext) {
|
|
237
236
|
filename += '.jpeg';
|
|
238
237
|
} else {
|
|
@@ -363,8 +362,13 @@ export default class FileCache {
|
|
|
363
362
|
const fileName = options.filename || false;
|
|
364
363
|
const filePath = join(this.cacheDir, `report-${fileName}.csv`);
|
|
365
364
|
|
|
366
|
-
const
|
|
367
|
-
|
|
365
|
+
const seen = new Set();
|
|
366
|
+
const dedupedData = report.data.filter((e) => {
|
|
367
|
+
if (seen.has(e.src)) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
seen.add(e.src);
|
|
371
|
+
return true;
|
|
368
372
|
});
|
|
369
373
|
|
|
370
374
|
const fileData = csv.jsonToCSV(dedupedData);
|
|
@@ -438,7 +442,7 @@ export default class FileCache {
|
|
|
438
442
|
hasFile(filename, type) {
|
|
439
443
|
let pathToCheck = filename;
|
|
440
444
|
|
|
441
|
-
if (type && !
|
|
445
|
+
if (type && !['tmp', 'json', 'image', 'zip'].includes(type)) {
|
|
442
446
|
throw new errors.NotFoundError({message: 'Unknown file type'});
|
|
443
447
|
} else if (type) {
|
|
444
448
|
pathToCheck = join(this[`${type}Dir`], filename);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-fs-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/TryGhost/migrate.git",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"csv-parse": "6.2.1",
|
|
31
31
|
"dotenv": "17.4.1",
|
|
32
32
|
"fs-extra": "11.3.4",
|
|
33
|
-
"lodash": "4.18.1",
|
|
34
33
|
"sharp": "0.34.5",
|
|
35
34
|
"transliteration": "2.6.1"
|
|
36
35
|
},
|