
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
gulp-file-version
Advanced tools
npm install gulp-file-version
###Example
#### Before
<html>
...
<script src="./common/app.js"></script>
...
</html>
### After
<html>
...
<script src="./common/app.js?v=12fa31"></script>
...
</html>
###Code
gulp.task("fv", function (cb) {
return gulp.src("./dist/*.html")//your source file
.pipe(fv())//use gulp-file-version to add version information of script and link's reference
.pipe(gulp.dest("./dist"));//output
});
##API #####fv(Regexp[, options]) Use custom regexp match source file.Add version info to the matched element, which is a file and must be existed. options: < Object >
Example:
gulp.task("tv", function(cb){//匹配angularjs中templateUrl引用文件并添加版本信息
return gulp.src("./dist/**/*.js")
.pipe(fv(/templateUrl:["']{1}([\w./-]*)["']{1}/g,{base: "./app", Hash: "md5"}))
.pipe(gulp.dest("./dist"));
});
Result:
path ./app/assets.js
###Before
...
var something = {
templateUrl:"./assets/assets.html"
};
...
###After
...
var something = {
templateUrl:"./assets/assets.html?v=ed36a41cd9"
};
...
PS: the old version before 2.0.0 of has been deprecated.The new version is more easy to use,and less error.
###示例
#### Before
<html>
...
<script src="./common/app.js"></script>
...
</html>
### After
<html>
...
<script src="./common/app.js?v=12fa31"></script>
...
</html>
###代码
gulp.task("fv", function (cb) {
return gulp.src("./dist/*.html")//你的源文件
.pipe(fv())//运行gulp-file-version,为文件中的script和link引用文件添加版本
.pipe(gulp.dest("./dist"));//输出
});
##API #####fv(Regexp[, options]) 用自定义的正则表达式匹配源文件内容,为其中满足条件的匹配项(文件路径)添加版本信息(该文件必须存在,否则报错) options: < Object >
Example:
gulp.task("tv", function(cb){//匹配angularjs中templateUrl引用文件并添加版本信息
return gulp.src("./dist/**/*.js")
.pipe(fv(/templateUrl:["']{1}([\w./-]*)["']{1}/g,{base: "./app", Hash: "md5"}))
.pipe(gulp.dest("./dist"));
});
Result:
path ./app/assets.js
###Before
...
var something = {
templateUrl:"./assets/assets.html"
};
...
###After
...
var something = {
templateUrl:"./assets/assets.html?v=ed36a41cd9"
};
...
PS: 2.0.0之前的旧版本已经弃用。新版本使用更为简单且错误更少。
FAQs
Add suffix to reference.
We found that gulp-file-version 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.