cache-busted
Advanced tools
Comparing version 1.1.1 to 1.2.0
24
index.js
@@ -1,8 +0,5 @@ | ||
var gitDescribe = require('git-describe').gitDescribeSync; | ||
var cacheBust = module.exports = function cacheBust (options) { | ||
var defaults = { | ||
version: null, | ||
packageLocation: __dirname + '/../../package.json', | ||
useGitHash: false | ||
packageLocation: __dirname + '/../../package.json' | ||
}; | ||
@@ -12,5 +9,5 @@ | ||
version: options.version || defaults.version, | ||
packageLocation: options.packageLocation || defaults.packageLocation, | ||
useGitHash: options.useGitHash || defaults.useGitHash, | ||
packageLocation: options.packageLocation || defaults.packageLocation | ||
} : defaults; | ||
if (!options.version) { | ||
@@ -24,12 +21,7 @@ try { | ||
var gitHash = ''; | ||
if (options.useGitHash) { | ||
gitHash = cacheBust.getGitHash(); | ||
} | ||
var querystring; | ||
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'integration') { | ||
querystring = options.version + (gitHash ? '-' + gitHash : ''); | ||
if (process.env.NODE_ENV === 'production') { | ||
querystring = options.version; | ||
} else { | ||
querystring = options.version + (gitHash ? '-' + gitHash : '') + '-' + cacheBust.getTimestamp(); | ||
querystring = options.version + '-' + cacheBust.getTimestamp(); | ||
} | ||
@@ -57,6 +49,2 @@ | ||
cacheBust.getGitHash = function getGitHash () { | ||
return gitDescribe().hash; | ||
} | ||
function getType (ressource) { | ||
@@ -63,0 +51,0 @@ var extension = ressource.split('.').pop(); |
{ | ||
"name": "cache-busted", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "A simplistic cache buster that appends the current version for production environments and the current time otherwise (great for development)", | ||
@@ -23,6 +23,3 @@ "main": "index.js", | ||
"sinon": "^1.14.1" | ||
}, | ||
"dependencies": { | ||
"git-describe": "^3.0.0" | ||
} | ||
} |
@@ -42,3 +42,2 @@ # cache-bust | ||
`packageLocation`: Path to the `package.json`. Defaults to `../../package.json`. | ||
`useGitHash`: (optional) The current git hash which will be appended to the version. | ||
@@ -45,0 +44,0 @@ ## Difference production and development |
@@ -12,3 +12,2 @@ var cacheBust = require('../'); | ||
this.sandbox.stub(cacheBust, 'getTimestamp').returns('12345'); | ||
this.sandbox.stub(cacheBust, 'getGitHash').returns('abc123'); | ||
}); | ||
@@ -67,8 +66,2 @@ | ||
}); | ||
it('should add a git hash if option useGitHash is set', function () { | ||
var fn = cacheBust({ packageLocation: './test/package-test.json', useGitHash: true }); | ||
var out = fn('/scripts/app', 'js'); | ||
assert.equal(out, '<script src="/scripts/app?v=1.0.0-abc123-12345"></script>'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
6
5779
103
50
- Removedgit-describe@^3.0.0
- Removedgit-describe@3.0.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedsemver@5.7.2(transitive)