Skip to content

Commit e97f844

Browse files
committed
Release v1.5.2
1 parent 51c8884 commit e97f844

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

dist/rev-web-assets.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! rev-web-assets v1.5.1 ~~ https://github.com/center-key/rev-web-assets ~~ MIT License
1+
//! rev-web-assets v1.5.3 ~~ https://github.com/center-key/rev-web-assets ~~ MIT License
22

33
export type Settings = {
44
cd: string | null;
@@ -7,6 +7,10 @@ export type Settings = {
77
saveManifest: boolean;
88
skip: string | null;
99
};
10+
export type MissingAsset = {
11+
ext: string;
12+
line: string;
13+
};
1014
export type ManifestDetail = {
1115
origin: string;
1216
filename: string;
@@ -22,7 +26,7 @@ export type ManifestDetail = {
2226
usedIn: string[] | null;
2327
references: number | null;
2428
skipped: boolean;
25-
missing: string[] | null;
29+
missing: MissingAsset[] | null;
2630
};
2731
export type Manifest = ManifestDetail[];
2832
export type Results = {

dist/rev-web-assets.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! rev-web-assets v1.5.1 ~~ https://github.com/center-key/rev-web-assets ~~ MIT License
1+
//! rev-web-assets v1.5.3 ~~ https://github.com/center-key/rev-web-assets ~~ MIT License
22

33
import { EOL } from 'node:os';
44
import chalk from 'chalk';
@@ -62,22 +62,24 @@ const revWebAssets = {
6262
hashAssetPath(manifest, detail, settings) {
6363
const webPages = ['.html', '.htm', '.php'];
6464
const replacer = (matched, pre, url, post) => {
65+
const line = matched.replace(/\s+/g, ' ');
6566
const uri = url.replace(/[#?].*/, '');
6667
const ext = path.extname(uri);
67-
const doNotHash = uri.includes(':') || webPages.includes(ext) || ext.length < 2;
68+
const isTemplate = /{.*}|<.*>|~~.*~~/.test(uri);
69+
const unhashable = uri.includes(':') || webPages.includes(ext) || ext.length < 2;
6870
const canonicalPath = detail.canonicalFolder ? detail.canonicalFolder + '/' : '';
6971
const canonical = slash(path.normalize(canonicalPath + uri));
7072
const isAssetDetail = (detail) => detail.canonical === canonical;
71-
const assetDetail = doNotHash ? null : manifest.find(isAssetDetail);
73+
const assetDetail = isTemplate || unhashable ? null : manifest.find(isAssetDetail);
7274
const skipAsset = !!settings.skip && uri.includes(settings.skip);
7375
if (assetDetail && !assetDetail.hash && !skipAsset)
7476
revWebAssets.calcAssetHash(assetDetail);
7577
if (assetDetail)
7678
assetDetail.references++;
7779
if (assetDetail && !assetDetail.usedIn.includes(detail.canonical))
7880
assetDetail.usedIn.push(detail.canonical);
79-
if (!doNotHash && !skipAsset && !assetDetail)
80-
detail.missing.push(matched.replace(/\s+/g, ' '));
81+
if (!isTemplate && !unhashable && !skipAsset && !assetDetail)
82+
detail.missing.push({ ext, line });
8183
const trailingSlashes = /\/*$/;
8284
const metaContentBase = settings.metaContentBase?.replace(trailingSlashes, '/');
8385
const absoluteUrl = () => `${metaContentBase}${assetDetail?.canonicalFolder}/${assetDetail?.hashedFilename}`;
@@ -185,14 +187,14 @@ const revWebAssets = {
185187
const arrow = { big: chalk.gray.bold(' ⟹ '), little: chalk.gray.bold('→') };
186188
const infoColor = results.count ? chalk.white : chalk.red.bold;
187189
const info = infoColor(`(files: ${results.count}, ${results.duration}ms)`);
188-
const warning = chalk.red.bold('missing asset in');
189190
log(name, source, arrow.big, target, info);
190191
const logDetail = (detail) => {
191192
const origin = chalk.white(detail.origin.substring(results.source.length + 1));
192193
const dest = chalk.green(detail.destPath.substring(results.target.length + 1));
193194
const file = chalk.blue.bold(detail.origin);
195+
const warning = (ext) => chalk.red.bold(`missing ${ext} asset in`);
194196
log(name, origin, arrow.little, dest);
195-
const logMissingAsset = (assetLine) => log(name, warning, file, arrow.little, chalk.green(assetLine));
197+
const logMissingAsset = (missing) => log(name, warning(missing.ext), file, arrow.little, chalk.green(missing.line));
196198
if (!settings.hide404s && detail.missing)
197199
detail.missing.forEach(logMissingAsset);
198200
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rev-web-assets",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "Revision web asset filenames with cache busting content hash fingerprints",
55
"license": "MIT",
66
"type": "module",

0 commit comments

Comments
 (0)