allbitsnbytes / asset_hash Goto Github PK
View Code? Open in Web Editor NEWNode module to hash filenames for static assets.
License: Other
Node module to hash filenames for static assets.
License: Other
First of all, awesome project!!!
I found a undesirable condition when there are a collection of files which have the same root name with digits designating their difference. I happen to be testing this repo with some favicon images when I discovered some files were being overwritten by the base root name file. The manifest generates correctly with all file paths/hashes intact but the resulting file renames/replaces were not as expected. Sorry for the output spew.
# Working file set:
['assets/ico/apple-touch-icon-114x114.png',
'assets/ico/apple-touch-icon-120x120.png',
'assets/ico/apple-touch-icon-144x144.png',
'assets/ico/apple-touch-icon-152x152.png',
'assets/ico/apple-touch-icon-180x180.png',
'assets/ico/apple-touch-icon-57x57.png',
'assets/ico/apple-touch-icon-60x60.png',
'assets/ico/apple-touch-icon-72x72.png',
'assets/ico/apple-touch-icon-76x76.png',
'assets/ico/apple-touch-icon-precomposed.png',
'assets/ico/apple-touch-icon.png',
'assets/ico/favicon-16x16.png',
'assets/ico/favicon-32x32.png',
'assets/ico/favicon-96x96.png',
'assets/ico/favicon.ico',
'assets/ico/open-graph.png' ]
Output from patterns:
[ 'assets/ico/apple-touch-icon-114x114-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-120x120-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-144x144-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-152x152-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-180x180-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-57x57-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-60x60-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-72x72-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-76x76-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-precomposed-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/apple-touch-icon-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/favicon-16x16-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/favicon-32x32-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/favicon-96x96-[0-9a-zA-Z_-]*.png' ]
[ 'assets/ico/favicon-[0-9a-zA-Z_-]*.ico' ]
[ 'assets/ico/open-graph-[0-9a-zA-Z_-]*.png' ]
Results from hash.hashFile():
setting: length: 10, hasher: md5, replace: true, save: true
-rw-r--r-- 1 keeda staff 5703 Jul 24 17:08 apple-touch-icon-df28e71904.png
-rw-r--r-- 1 keeda staff 449 Jul 24 17:08 favicon-16x16-ef085bbe7a.png
-rw-r--r-- 1 keeda staff 822 Jul 24 17:08 favicon-32x32-6f3f21e707.png
-rw-r--r-- 1 keeda staff 12290 Jul 24 17:08 favicon-8edcc9ed41.ico
-rw-r--r-- 1 keeda staff 2748 Jul 24 17:08 favicon-96x96-ac5751fe0e.png
-rw-r--r-- 1 keeda staff 12441 Jul 24 17:08 open-graph-26b88ace7f.png
I found this weird because the apple-touch-icon files were affected but the favicon files were not.
I then removed the asterisk from the replace string [0-9a-zA-Z_-]*
--> [0-9a-zA-Z_-]
resulting in:
[ 'assets/ico/apple-touch-icon-114x114-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-120x120-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-144x144-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-152x152-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-180x180-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-57x57-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-60x60-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-72x72-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-76x76-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-precomposed-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/apple-touch-icon-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/favicon-16x16-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/favicon-32x32-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/favicon-96x96-[0-9a-zA-Z_-].png' ]
[ 'assets/ico/favicon-[0-9a-zA-Z_-].ico' ]
[ 'assets/ico/open-graph-[0-9a-zA-Z_-].png' ]
with expected results:
-rw-r--r-- 1 keeda staff 3282 Jul 24 17:35 apple-touch-icon-114x114-ac5033118c.png
-rw-r--r-- 1 keeda staff 3444 Jul 24 17:35 apple-touch-icon-120x120-70fe6f7048.png
-rw-r--r-- 1 keeda staff 4388 Jul 24 17:35 apple-touch-icon-144x144-9468b78d7a.png
-rw-r--r-- 1 keeda staff 4487 Jul 24 17:35 apple-touch-icon-152x152-3dfbd760a2.png
-rw-r--r-- 1 keeda staff 5703 Jul 24 17:35 apple-touch-icon-180x180-df28e71904.png
-rw-r--r-- 1 keeda staff 1488 Jul 24 17:35 apple-touch-icon-57x57-406cae6c1f.png
-rw-r--r-- 1 keeda staff 1623 Jul 24 17:35 apple-touch-icon-60x60-70719ffbc6.png
-rw-r--r-- 1 keeda staff 1906 Jul 24 17:35 apple-touch-icon-72x72-db94d99b53.png
-rw-r--r-- 1 keeda staff 2114 Jul 24 17:35 apple-touch-icon-76x76-0c0ddc766f.png
-rw-r--r-- 1 keeda staff 5703 Jul 24 17:35 apple-touch-icon-df28e71904.png
-rw-r--r-- 1 keeda staff 5703 Jul 24 17:35 apple-touch-icon-precomposed-df28e71904.png
-rw-r--r-- 1 keeda staff 449 Jul 24 17:35 favicon-16x16-ef085bbe7a.png
-rw-r--r-- 1 keeda staff 822 Jul 24 17:35 favicon-32x32-6f3f21e707.png
-rw-r--r-- 1 keeda staff 12290 Jul 24 17:35 favicon-8edcc9ed41.ico
-rw-r--r-- 1 keeda staff 2748 Jul 24 17:35 favicon-96x96-ac5751fe0e.png
-rw-r--r-- 1 keeda staff 12441 Jul 24 17:35 open-graph-26b88ace7f.png
Since I am unsure whether this was intended or not, I do nothing. Just wanted you to be aware. If you need a PR, just say the word. But this is a minor edit...quick update will do if this is unintended. And I don't write tests. At least not yet. I just TEST ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.