grunt-yate
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -35,3 +35,6 @@ /* | ||
files: { | ||
'tmp/simple.js': 'test/fixtures/simple.yate' | ||
'tmp/simple.js': [ | ||
'test/fixtures/simple.yate', | ||
'test/fixtures/externals.yate' | ||
] | ||
} | ||
@@ -38,0 +41,0 @@ }, |
{ | ||
"name": "grunt-yate", | ||
"description": "Yate compiler plugin", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"homepage": "https://github.com/lapple/grunt-yate", | ||
@@ -41,3 +41,4 @@ "author": { | ||
"dependencies": { | ||
"yate": ">=0.0.32" | ||
"yate": ">=0.0.32", | ||
"temporary": "0.0.5" | ||
}, | ||
@@ -44,0 +45,0 @@ "keywords": [ |
@@ -53,2 +53,8 @@ # grunt-yate | ||
#### options.modular | ||
Type: `Boolean` | ||
Default value: `false` | ||
`module.exports` main template function so that it can be required as a node module. | ||
#### options.externals | ||
@@ -55,0 +61,0 @@ Type: `String|Array` |
@@ -11,5 +11,7 @@ /* | ||
var path = require('path'); | ||
var yate = require('yate'); | ||
var path = require('path'); | ||
var TempFile = require('temporary/lib/file'); | ||
var yateFolder = path.dirname(require.resolve('yate')); | ||
@@ -26,2 +28,3 @@ | ||
autorun: false, | ||
modular: false, | ||
@@ -45,30 +48,31 @@ // List of externals-containing files to be added to the compiled | ||
var temp = new TempFile(); | ||
var src; | ||
// Building compiled templates. | ||
var src = f.src.filter(function(filepath) { | ||
temp.writeFileSync( | ||
f.src.filter(function(filepath) { | ||
// Warn on and remove invalid source | ||
// files (if nonull was set). | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
// Warn on and remove invalid source | ||
// files (if nonull was set). | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}).map(function(filepath) { | ||
var compiled; | ||
}).map(function(filepath) { | ||
return 'include "' + path.resolve(filepath) + '"'; | ||
}).join(grunt.util.linefeed) | ||
); | ||
try { | ||
compiled = yate.compile(filepath).js; | ||
} catch(e) { | ||
failure = true; | ||
try { | ||
src = yate.compile(temp.path).js; | ||
} catch(e) { | ||
grunt.event.emit('yate:error', e); | ||
grunt.fail.warn(e); | ||
grunt.event.emit('yate:error', e); | ||
grunt.fail.warn(e); | ||
} | ||
temp.unlink(); | ||
return compiled; | ||
}).join(grunt.util.linefeed); | ||
if (failure) { | ||
return next(); | ||
@@ -95,2 +99,4 @@ } | ||
src = autorun(src, options.autorun); | ||
} else if (options.modular) { | ||
src = modular(src); | ||
} | ||
@@ -105,2 +111,3 @@ | ||
grunt.log.writeln('File ' + f.dest.cyan + ' created.'); | ||
temp.unlink(); | ||
next(); | ||
@@ -118,2 +125,6 @@ }); | ||
function modular(code) { | ||
return iife(code + grunt.util.linefeed + 'module.exports = function(data) { return yr.run("main", data); };'); | ||
} | ||
function iife(code) { | ||
@@ -120,0 +131,0 @@ return '(function(){' + grunt.util.linefeed + code + grunt.util.linefeed + '})()' + grunt.util.linefeed; |
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
14881
324
128
4
+ Addedtemporary@0.0.5
+ Addedpackage@1.0.1(transitive)
+ Addedtemporary@0.0.5(transitive)