New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-update-reference

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-update-reference - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

11

lib/version.js

@@ -37,3 +37,3 @@

logAll( "Scan above files' reference in "+ path.green );
logAll( "Scan changed files' reference in "+ path.green );
grunt.file.recurse( path, function ( abspath, rootdir, subdir, filename ) {

@@ -44,8 +44,7 @@

var i;
var flagIsHit = false;
var contents = grunt.file.read( abspath );
for ( i in newFileName ) {
var regx = new RegExp( "(?!\\n|\\r\\n*)(.+)" + "(" + newFileName[ i ] + "[^\"|\'|\\)]*)(?=\"|\'|\\))(.*)", "g" );
newFileName.forEach( function ( oneFile ) {
var regx = new RegExp( "(?!\\n|\\r\\n*)(.+)" + "(" + oneFile + "[^\"|\'|\\)]*)(?=\"|\'|\\))(.*)", "g" );

@@ -57,3 +56,3 @@ contents = contents.replace( regx, function () {

logSimple( "refresh " + newFileName[ i ].blue + "'s reference in " + filename.yellow );
logSimple( "refresh " + oneFile.blue + "'s reference in " + filename.yellow );

@@ -69,3 +68,3 @@ logAll( "in file " + filename.yellow + " replace:" );

} )
}
});

@@ -72,0 +71,0 @@ //避免没有实际更新时也重写文件,导致newer失效

{
"name": "grunt-update-reference",
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "devDependencies": {

# grunt-update-reference
Grunt task for updating the newer changed resources's reference, to achieve cache bust.
Grunt task for updating the newer changed resources's reference, to get cache bust.
## Feature
It can also instantly update reference of one file which its content not changed by us, but changed by this task(updating reference).
It can also instantly update reference of one file which its content not changed by us, but changed by this task.

@@ -14,2 +14,4 @@ It can identify the newer file(first run will consider all match file is newer), it will configure other two task to achieve it (newer check is achieved by [grunt-newer](https://github.com/tschaub/grunt-newer),

It will only hit the file name, need not match the entire path.
## Getting Started

@@ -37,3 +39,3 @@

//If has some file or path to ignore, path is base on "options.searchPathBase".
searchIgnore:[],
searchIgnore:[ "dont_touch_me.html","dont_touch_me/**/*" ],
//True to enble newer check. Default is true. Set false to prevent checking newer file.

@@ -47,8 +49,8 @@ newer:true,

//The base path.
searchPathBase: "./path",
searchPathBase: "./path_to",
//Prevent watch instantly changes, which changed by this task.
referenceIgnore:["*.html"]
},
//What kind of files are referenced in 'searchFile'.
src: [ "path/**/*.{css,js,jpg,png,gif}" ]
//What kind of files that may needed to be update references.(path is not base on "options.searchPathBase")
src: [ "path_to/**/*.{css,js,jpg,png,gif}" ]
}

@@ -59,2 +61,17 @@ }

It is recommended to set `newer` task's `cache` folder to version controlled, to prevent conflict(repeatedly update reference) when project has muti contributors.
so it's best to add [newer.option.cache](https://github.com/tschaub/grunt-newer#options-for-the-newer-task) to `initConfig`:
```js
grunt.initConfig({
...
newer: {
options: {
cache: './path_to_newer_cache_folder'
}
}
});
```
Run the `grunt reference` task:

@@ -66,11 +83,11 @@

$ grunt reference
Running "reference:dist" (reference) task
Preparing TO Check New Files...
Running "newer:reference_core:dist__path_to" (newer) task
Running "reference_core:dist__path_to" (reference_core) task
Running "newer:reference_core:dist__path" (newer) task
Running "reference_core:dist__path" (reference_core) task
File Changed: foo.jpg
refresh foo.jpg's reference in bar.css
refresh bar.css's reference in index.html
Done, without errors.

@@ -83,10 +100,9 @@ ```

$ grunt reference
Running "reference:dist" (reference) task
Preparing TO Check New Files...
Running "newer:reference_core:dist__path_to" (newer) task
Running "reference_core:dist__path_to" (reference_core) task
Running "newer:reference_core:dist__path" (newer) task
Running "reference_core:dist__path" (reference_core) task
File Changed: foo.jpg
Scan above files' reference in ./path
Scan changed files' reference in ./path_to
in file bar.css replace:

@@ -97,3 +113,3 @@ background:url("./foo.jpg");

File bar.css instantly changed, rescan path.
+ scan files in ./path
+ Scan changed files' reference in ./path_to
+ in file index.html replace:

@@ -100,0 +116,0 @@ + <link href="./bar.css?v=2" rel="stylesheet" type="text/css" />

@@ -28,3 +28,3 @@

} );
grunt.log.writeln( "Preparing TO Check New Files...".cyan );
//grunt.log.writeln( "Preparing TO Check New Files...".cyan );
grunt.task.run( [ newer+"reference_core:" + taskName ] );

@@ -31,0 +31,0 @@ });

+function () {
//reference css file;
var css = "./base.css?t=1458117005346",
xcss = "./xcss/base.css?t=1458117005346";
var css = "./base.css?t=1458532029095",
xcss = "./xcss/base.css?t=1458532029095";
}();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc