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

grunt-yate

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-yate - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

5

Gruntfile.js

@@ -41,3 +41,6 @@ /*

autorun: true,
externals: 'test/fixtures/externals.js'
runtime: true,
externals: [
'test/fixtures/externals.js'
]
},

@@ -44,0 +47,0 @@ files: {

2

package.json
{
"name": "grunt-yate",
"description": "Yate compiler plugin",
"version": "0.0.6",
"version": "0.0.7",
"homepage": "https://github.com/lapple/grunt-yate",

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

@@ -53,2 +53,8 @@ # grunt-yate

#### options.externals
Type: `String|Array`
File pattern or array of patterns to load external functions from. Functions should be
defined in `yr.externals` namespace.
#### options.postprocess

@@ -55,0 +61,0 @@ Type: `Function`

@@ -18,2 +18,4 @@ /*

var async = grunt.util.async;
grunt.registerMultiTask('yate', 'Yate compiler plugin', function() {

@@ -37,3 +39,3 @@

// Iterate over all specified file groups.
this.files.forEach(function(f) {
async.forEachSeries(this.files, function(f, next) {

@@ -54,34 +56,36 @@ // Building compiled templates.

return yate.compile(filepath).js;
}).join('\n');
}).join(grunt.util.linefeed);
// Building a list of files to prepend to the compiled template.
var includes = grunt.file.expand(options.externals);
// It is important to prepend externals with runtime.
if (options.runtime) {
src = runtime(src);
includes.unshift(path.join(yateFolder, 'runtime.js'));
}
// It is important to append externals after runtime.
src = externals(src, options.externals);
async.map(includes, readFile, function(err, scripts) {
if (err) {
grunt.log.warn(err);
return next(false);
}
if (options.autorun) {
src = autorun(src, options.autorun);
}
src = scripts.join(grunt.util.linefeed) + grunt.util.linefeed + src;
src = options.postprocess(src);
if (options.autorun) {
src = autorun(src, options.autorun);
}
// Write the destination file.
grunt.file.write(f.dest, src);
src = options.postprocess(src);
// Print a success message.
grunt.log.writeln('File ' + f.dest.cyan + ' created.');
});
});
// Write the destination file.
grunt.file.write(f.dest, src);
function externals(code, externals) {
return [code].concat(grunt.file.expand(externals).map(function(path) {
return grunt.file.read(path);
})).join(grunt.util.linefeed);
}
// Print a success message.
grunt.log.writeln('File ' + f.dest.cyan + ' created.');
next();
});
function runtime(code) {
return grunt.file.read(path.join(yateFolder, 'runtime.js')) + '\n' + code;
}
}, this.async());
});

@@ -91,9 +95,13 @@ function autorun(code, module) {

return iife(code + '\nreturn function(data) { return yr.run("' + main + '", data); };');
return iife(code + grunt.util.linefeed + 'return function(data) { return yr.run("' + main + '", data); };');
}
function iife(code) {
return '(function(){\n' + code + '\n})()\n';
return '(function(){' + grunt.util.linefeed + code + grunt.util.linefeed + '})()' + grunt.util.linefeed;
}
function readFile(path, callback) {
return require('fs').readFile(path, { encoding: 'utf8' }, callback);
}
};
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