This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
forked from sindresorhus/gulp-rev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 64604d2
Showing
9 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"node": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 4, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "single", | ||
"regexp": true, | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"trailing": true, | ||
"smarttabs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
var crypto = require('crypto'); | ||
var path = require('path'); | ||
var es = require('event-stream'); | ||
|
||
function md5(str) { | ||
return crypto.createHash('md5').update(str, 'utf8').digest('hex'); | ||
} | ||
|
||
module.exports = function (data, options) { | ||
return es.map(function (file, cb) { | ||
var filename = md5(file.contents.toString()).slice(0, 8) + '.' + path.basename(file.path); | ||
file.path = path.join(path.dirname(file.path), filename); | ||
cb(null, file); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "gulp-rev", | ||
"version": "0.0.0", | ||
"description": "Static asset revisioning by prepending content hash to filenames: unicorn.css => 098f6bcd.unicorn.css", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-rev", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "http://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"gulpplugin", | ||
"rev", | ||
"revision", | ||
"hash", | ||
"optimize", | ||
"version", | ||
"versioning", | ||
"cache", | ||
"expire", | ||
"static", | ||
"asset", | ||
"assets" | ||
], | ||
"dependencies": { | ||
"event-stream": "~3.0.20" | ||
}, | ||
"devDependencies": { | ||
"gulp-util": "~2.1.3", | ||
"mocha": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# [gulp](https://github.com/wearefractal/gulp)-rev [![Build Status](https://secure.travis-ci.org/sindresorhus/gulp-rev.png?branch=master)](http://travis-ci.org/sindresorhus/gulp-rev) | ||
|
||
> Static asset revisioning by prepending content hash to filenames | ||
`unicorn.css` => `098f6bcd.unicorn.css` | ||
Make sure to set the files to [never expire](http://developer.yahoo.com/performance/rules.html#expires) for this to have an effect. | ||
|
||
|
||
## Install | ||
|
||
Install with [npm](https://npmjs.org/package/gulp-rev) | ||
|
||
``` | ||
npm install --save-dev gulp-rev | ||
``` | ||
|
||
|
||
## Example | ||
|
||
```js | ||
var gulp = require('gulp'); | ||
var rev = require('gulp-rev'); | ||
|
||
gulp.task('default', function () { | ||
gulp.src('src/*.css') | ||
.pipe(rev()) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
``` | ||
|
||
|
||
## License | ||
|
||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
var assert = require('assert'); | ||
var path = require('path'); | ||
var gutil = require('gulp-util'); | ||
var rev = require('./index'); | ||
|
||
it('should rev files', function (cb) { | ||
var stream = rev(); | ||
|
||
stream.on('data', function (data) { | ||
assert.equal(data.path, '~/dev/foo/098f6bcd.unicorn.css'); | ||
cb(); | ||
}); | ||
|
||
stream.write(new gutil.File({ | ||
path: '~/dev/foo/unicorn.css', | ||
contents: 'test' | ||
})); | ||
}); |