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

grunt-replace-dojo-cache

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-replace-dojo-cache - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

package.json
{
"name": "grunt-replace-dojo-cache",
"description": "Replace calls to dojo.cache in JavaScript source with the contents of the referred file.",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://github.com/bvanreeven/grunt-replace-dojo-cache",

@@ -6,0 +6,0 @@ "author": {

@@ -68,3 +68,4 @@ # grunt-replace-dojo-cache

## Release History
* 2013-04-25   v0.1.2   Remove `dojo.require("dojo.cache");` calls to prevent unnecessary requests.
* 2013-04-21   v0.1.1   Added support for multiple dots in the package name.
* 2013-04-21   v0.1.0   Initial version.

@@ -24,16 +24,10 @@ /*

// Iterate over all specified file groups.
this.files.forEach(function (f) {
if (f.src.length !== 1) {
grunt.fail.fatal("Must specify exactly one source file per destination.");
return;
}
var replaceRequires = function (src) {
var regex = /^\s*dojo\.require\(['"]dojo\.cache['"]\);$/gm;
return src.replace(regex, "");
};
if (!grunt.file.exists(f.src[0])) {
grunt.fail.fatal('Source file "' + f.src[0] + '" not found.');
return;
}
var replaceCalls = function (src) {
var regex = /dojo\.cache\(['"]([a-zA-Z.]+)['"]\s*,\s*['"]([a-zA-Z.]+)['"]\)/g;
var src = grunt.file.read(f.src[0]).replace(regex, function (match, packageName, fileName) {
return src.replace(regex, function (match, packageName, fileName) {

@@ -52,3 +46,20 @@ var cacheFilePath = path.join(options.basePath, packageName.replace(/\./g, "/"), fileName);

});
};
// Iterate over all specified file groups.
this.files.forEach(function (f) {
if (f.src.length !== 1) {
grunt.fail.fatal("Must specify exactly one source file per destination.");
return;
}
if (!grunt.file.exists(f.src[0])) {
grunt.fail.fatal('Source file "' + f.src[0] + '" not found.');
return;
}
var src = grunt.file.read(f.src[0]);
src = replaceRequires(src);
src = replaceCalls(src);
// Write the destination file.

@@ -55,0 +66,0 @@ grunt.file.write(f.dest, src);

@@ -5,3 +5,2 @@ /*jslint indent: 4, forin: true */

dojo.require("dojo.cache");
dojo.require("dojo.NodeList-traverse");

@@ -8,0 +7,0 @@ dojo.require("buzz.widget.lib.mustache");

@@ -5,3 +5,2 @@ /*jslint indent: 4, forin: true */

dojo.require("dojo.cache");
dojo.require("dojo.NodeList-traverse");

@@ -8,0 +7,0 @@ dojo.require("buzz.widget.lib.mustache");

@@ -5,3 +5,2 @@ /*jslint indent: 4, forin: true */

dojo.require("dojo.cache");
dojo.require("dojo.NodeList-traverse");

@@ -8,0 +7,0 @@ dojo.require("buzz.widget.lib.mustache");

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