Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cache-busted

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-busted - npm Package Compare versions

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>');
});
});
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