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.4 to 0.0.5

test/expected/autorun.js

21

Gruntfile.js

@@ -33,17 +33,14 @@ /*

yate: {
sample: {
simple: {
files: {
'tmp/hello.js': 'test/fixtures/hello.yate'
'tmp/simple.js': 'test/fixtures/simple.yate'
}
},
oneToOne: {
files: [
{
src: [ 'test/fixtures/multiple/*.yate' ],
dest: 'tmp/',
ext: '.js',
flatten: true,
expand: true
}
]
autorun: {
options: {
autorun: true
},
files: {
'tmp/autorun.js': 'test/fixtures/autorun.yate'
}
}

@@ -50,0 +47,0 @@ },

{
"name": "grunt-yate",
"description": "Yate compiler plugin",
"version": "0.0.4",
"version": "0.0.5",
"homepage": "https://github.com/lapple/grunt-yate",

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

@@ -40,18 +40,19 @@ # grunt-yate

#### options.iife
Type: `Boolean`
Default value: `true`
Wrap the compiled templates into [IIFE](http://benalman.com/news/2010/11/immediately-invoked-function-expression/).
#### options.runtime
Type: `Boolean`
Default value: `true`
Default value: `false`
Prepend destination file with `runtime.js` library from [yate](https://github.com/pasaran/yate).
#### options.autorun
Type: `Boolean|String`
Default value: `false`
Create autorunning templates. Pass `true` to automatically run `main` module. Pass
a module title to autorun specific module.
#### options.postprocess
Type: `Function`
Define compiled code transformations. For instance, one can create autorunning templates:
Define compiled code transformation or extension.

@@ -63,4 +64,4 @@ ```javascript

postprocess: function(code) {
// Autorun the `main` module.
return code + '\nreturn function(data) { return yr.run("main", data); };';
// Example: augment particular strings at compile time:
return code.replace('{time}', Date.now());
}

@@ -75,5 +76,2 @@ }

When using default options each destination file is wrapped into IIFE
and prepended by `runtime.js`.
Compile single file:

@@ -80,0 +78,0 @@

@@ -21,5 +21,5 @@ /*

var options = this.options({
runtime: true,
iife: true,
runtime: false,
autorun: false,
// Default no-op postprocess function. Use `postprocess`

@@ -51,3 +51,2 @@ // to define custom compiled code transformations.

src = options.postprocess(src);

@@ -58,6 +57,8 @@ if (options.runtime) {

if (options.iife) {
src = iife(src);
if (options.autorun) {
src = autorun(src, options.autorun);
}
src = options.postprocess(src);
// Write the destination file.

@@ -75,2 +76,8 @@ grunt.file.write(f.dest, src);

function autorun(code, module) {
var main = typeof module === 'string' ? module : 'main';
return iife(code + '\nreturn function(data) { return yr.run("' + main + '", data); };');
}
function iife(code) {

@@ -77,0 +84,0 @@ return '(function(){\n' + code + '\n})()\n';

@@ -30,11 +30,20 @@ 'use strict';

},
hello: function(test) {
simple: function(test) {
test.expect(1);
var actual = grunt.file.read('tmp/hello.js');
var expected = grunt.file.read('test/expected/hello.js');
var actual = grunt.file.read('tmp/simple.js').trim();
var expected = grunt.file.read('test/expected/simple.js').trim();
test.equal(actual, expected);
test.done();
},
autorun: function(test) {
test.expect(1);
var actual = grunt.file.read('tmp/autorun.js').trim();
var expected = grunt.file.read('test/expected/autorun.js').trim();
test.equal(actual, expected);
test.done();
}
};
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