Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
borodean committed Mar 11, 2015
2 parents 7188ced + c46dc9e commit 20f1092
Show file tree
Hide file tree
Showing 24 changed files with 518 additions and 437 deletions.
16 changes: 16 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"bitwise": true,
"curly": true,
"devel": true,
"eqeqeq": true,
"eqnull": true,
"latedef": true,
"loopfunc": true,
"mocha": true,
"noarg": true,
"node": true,
"nonbsp": true,
"nonew": true,
"undef": true,
"unused": true
}
41 changes: 41 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var gulp = require('gulp');

var javascripts = [
'Gulpfile.js',
'index.js',
'lib/**/*.js',
'test/**/*.js'
];

gulp.task('jscs', function () {
var jscs = require('gulp-jscs');
return gulp.src(javascripts)
.pipe(jscs({
preset: 'yandex',
disallowMultipleVarDecl: 'exceptUndefined'
}));
});

gulp.task('lint', function () {
var jshint = require('gulp-jshint');
return gulp.src(javascripts)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});

gulp.task('test', function () {
var mocha = require('gulp-mocha');
return gulp.src('test/**/*.js', {
read: false
})
.pipe(mocha({
bail: true
}));
});

gulp.task('watch', function () {
return gulp.watch(javascripts, ['default']);
});

gulp.task('default', ['lint', 'jscs', 'test']);
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,32 @@ To define a custom cachebuster pass a function as an option:

```js
var options = {
cachebuster: function (path) {
return fs.statSync(path).mtime.getTime().toString(16);
cachebuster: function (filePath, urlPathname) {
return fs.statSync(filePath).mtime.getTime().toString(16);
}
};
```

If the returned value is falsy, no cache busting is done for the asset.

If the returned value is an object the values of `pathname` and/or `query` are used to generate a cache busted path to the asset.

If the returned value is a string, it is added as a query string.

The returned values for query strings must not include the starting `?`.

Busting the cache via path:

```js
var options = {
cachebuster: function (filePath, urlPathname) {
var hash = fs.statSync(filePath).mtime.getTime().toString(16);
return {
pathname: path.dirname(urlPathname)
+ '/' + path.basename(urlPathname, path.extname(urlPathname))
+ hash + path.extname(urlPathname),
query: false // you may omit this one
}
}
};
```
Expand Down
Loading

0 comments on commit 20f1092

Please sign in to comment.