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

gulp-nunjucks-api

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-nunjucks-api - npm Package Compare versions

Comparing version 0.8.0 to 0.9.1

78

index.js

@@ -6,3 +6,2 @@ 'use strict';

var glob = require('glob');
var gutil = require('gulp-util');
var assign = require('lodash/assign');

@@ -13,4 +12,7 @@ var cloneDeep = require('lodash/cloneDeep');

var path = require('path');
var pluginError = require('plugin-error');
var requireNew = require('require-new');
var through = require('through2');
var fancyLog = require('fancy-log');
var replaceExt = require('replace-ext');

@@ -123,3 +125,2 @@ // #region Configuration

config.verbose = options.verbose || config.verbose;
config.vlog = config.verbose ? log : returnGulpUtil;
delete options.verbose;

@@ -146,17 +147,18 @@ }

function createError(message, opt) {
return new gutil.PluginError(PLUGIN_NAME, message, opt);
return new pluginError(PLUGIN_NAME, message, opt);
}
function handleError(config, sender, err, cb, opt) {
config.vlog('Handling error: ' + err);
if (config.verbose) {
fancyLog.info('Handling error: ' + err);
}
var pluginErr = createError(err, opt);
if (config.errors)
if (config.errors) {
sender.emit('error', pluginErr);
}
return cb(pluginErr);
}
function log(message) {
return gutil.log.apply(gutil, arguments);
}
function requireFile(config, filepath, result) {

@@ -170,3 +172,3 @@ if (filepath === undefined || filepath === null)

catch (err) {
config.vlog('File not found: ' + filepath);
fancyLog.error('File not found: ' + filepath);
}

@@ -186,3 +188,6 @@ return false;

var pattern = locals;
config.vlog('Searching for locals with pattern:', pattern, 'in:', searchpath);
if (config.verbose) {
fancyLog.info('Searching for locals with pattern:', pattern, 'in:', searchpath);
}
var options = {

@@ -194,6 +199,12 @@ cwd: searchpath,

var i, fullpath, result;
config.vlog('Found:', found.length, 'locals files.');
if (config.verbose) {
fancyLog.info('Found:', found.length, 'locals files.');
}
for (i = 0; i < found.length; i++) {
fullpath = path.resolve(searchpath, found[i]);
config.vlog('Using locals file:', found[i], 'fullpath:', fullpath);
if (config.verbose) {
fancyLog.info('Using locals file:', found[i], 'fullpath:', fullpath);
}
result = {};

@@ -218,17 +229,30 @@ if (requireFile(config, fullpath, result))

}
if (file.isStream())
if (file.isStream()) {
return handleError(config, _this, 'Streaming not supported', cb);
if (file.data)
}
if (file.data) {
assign(context, file.data);
if (config.locals)
}
if (config.locals) {
assignLocals(context, config, file);
config.vlog('Rendering nunjucks file.path:', file.path);
}
if (config.verbose) {
fancyLog.info('Rendering nunjucks file.path:', file.path);
}
if (config.renderString) {
env.renderString(file.contents.toString(), context, function(err, result) {
if (err)
if (err) {
return handleError(config, _this, err, cb);
}
file.contents = new Buffer(result);
if (config.extension !== 'inherit')
file.path = gutil.replaceExtension(file.path, config.extension);
if (config.extension !== 'inherit'){
file.path = replaceExt(file.path, config.extension);
}
_this.push(file);

@@ -239,7 +263,11 @@ cb();

env.render(file.path, context, function (err, result) {
if (err)
if (err){
return handleError(config, _this, err, cb);
}
file.contents = new Buffer(result);
if (config.extension !== 'inherit')
file.path = gutil.replaceExtension(file.path, config.extension);
if (config.extension !== 'inherit') {
file.path = replaceExt(file.path, config.extension);
}
_this.push(file);

@@ -271,5 +299,1 @@ cb();

plugin.nunjucks = nunjucks;
function returnGulpUtil() {
return gutil;
}
{
"name": "gulp-nunjucks-api",
"version": "0.8.0",
"version": "0.9.1",
"description": "Render Nunjucks templates with data, custom filters, custom context functions and options for other Nunjucks API features.",

@@ -31,6 +31,8 @@ "license": "MIT",

"dependencies": {
"fancy-log": "^1.3.3",
"glob": "^7.0.3",
"gulp-util": "^3.0.7",
"lodash": "^4.10.0",
"nunjucks": "^2.4.1",
"nunjucks": "^3.0.0",
"plugin-error": "^1.0.1",
"replace-ext": "^1.0.0",
"require-new": "^1.1.0",

@@ -40,4 +42,5 @@ "through2": "^2.0.1"

"devDependencies": {
"mocha": "^2.4.5",
"should": "^8.3.0"
"mocha": "^6.0.0",
"should": "^8.3.0",
"vinyl": "^2.2.0"
},

@@ -44,0 +47,0 @@ "readmeFilename": "readme.md",

@@ -0,3 +1,11 @@

<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
# gulp-nunjucks-api
[![npm version][npm-badge]][npm] [![npm downloads][npd-badge]][npm] [![dependencies Status][dps-badge]][dps]
> Render [Nunjucks](https://mozilla.github.io/nunjucks/) templates with data,

@@ -152,1 +160,7 @@ custom filters, custom context functions and options for other Nunjucks API

Nunjucks templates.
[npm-badge]: https://img.shields.io/npm/v/gulp-nunjucks-api?style=flat
[npd-badge]: https://img.shields.io/npm/dm/gulp-nunjucks-api.svg?style=flat-square
[dps-badge]: https://david-dm.org/waynebloss/gulp-nunjucks-api/status.svg
[dps]: https://david-dm.org/waynebloss/gulp-nunjucks-api
[npm]: https://www.npmjs.com/package/gulp-nunjucks-api

Sorry, the diff of this file is not supported yet

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