Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
asset-rev
Advanced tools
Readme
Append hash to assets and updates references in each file specified
This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies
:
npm install --save-dev asset-rev
or
yarn add -D asset-rev
With npm scripts you can do:
{
"scripts": {
"rev": "asset-rev dist 'scripts/**/*.* images/**/*.*'"
}
}
or with node
const rev = require('asset-rev');
const workingDir = 'dist';
const patterns = ['scripts/**/*.*', 'images/**/*.*'];
rev(workingDir, patterns);
asset-rev [workingDir] [patterns] [options]
workingDir
: Relative to your project root, specifies where the script should look for your patterns and also defines that all files in this folder will have their references of the rev'd files updated.patterns
: String of glob patterns for files to be rev'd inside the workingDir
. You can specify multiple globs separated by a space
and encapsulated by single quotes, 'test/*.* test1/*.*'
.options
:
--contenthash
: By default the hash generated will be random every time, if you would instead prefer the hash to be generated based on content then you can pass in this variable.--foldermatch
: By default this is set to true, asset-rev
will only hash strings it comes across if it is a complete 1 - 1 match when including the directory path relative to the workingDir
. It it preferred to keep this option enabled as you may come into issues if you have two files with the same name but in different folders, though if you have a path that is constructed through string concatenation then this can serve as an alternative.rev(workingDir, patterns).then(() => {
// ...
}).catch(err => {
// ...
});
workingDir
: Much like for the command line usage relative to your project root, this will be a string of where the script should look for your patterns and also defines that all files in this folder will have their references of the rev'd files updated.patterns
: This accepts an array of strings of glob patterns for the files to be rev'd inside the workingDir
.options
: typeof Object
contenthash
: Boolean variable that when passed in will generate the hash based on content, by default hashes are random each time.foldermatch
: Boolean variable that when passed in will take the full path into consideration for string matchesWhen specifying your globs, be careful that if your patterns match a dir name, that dir name will be rev'd. Whether or not this is desirable is up to you.
I created this little script as I wanted an alternative to grunt-usemin, but without grunt. I searched for quite a while and wasn't able to find a solid alternative that makes use of npm scripts so I decided to write my own.
MIT
FAQs
Append hash to assets and updates references in each file specified
We found that asset-rev demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).