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

pug-load

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pug-load - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

coverage/coverage.json

5

HISTORY.md

@@ -0,1 +1,6 @@

2.0.3 / 2016-08-24
==================
* Do not pollute the user's `options` object
2.0.2 / 2016-08-23

@@ -2,0 +7,0 @@ ==================

41

index.js

@@ -6,6 +6,7 @@ 'use strict';

var walk = require('pug-walk');
var assign = require('object-assign');
module.exports = load;
function load(ast, options) {
load.validateOptions(options);
options = getOptions(options);
// clone the ast

@@ -22,5 +23,5 @@ ast = JSON.parse(JSON.stringify(ast));

try {
path = (options.resolve || load.resolve)(file.path, file.filename, options);
path = options.resolve(file.path, file.filename, options);
file.fullPath = path;
str = (options.read || load.read)(path, options);
str = options.read(path, options);
} catch (ex) {

@@ -32,8 +33,5 @@ ex.message += '\n at ' + node.filename + ' line ' + node.line;

if (node.type === 'Extends' || node.type === 'Include') {
var childOptions = {};
Object.keys(options).forEach(function (key) {
childOptions[key] = options[key];
})
childOptions.filename = path;
file.ast = load.string(str, childOptions);
file.ast = load.string(str, assign({}, options, {
filename: path
}));
}

@@ -46,4 +44,5 @@ }

load.string = function loadString(src, options) {
load.validateOptions(options);
options.src = src;
options = assign(getOptions(options), {
src: src
});
var tokens = options.lex(src, options);

@@ -54,5 +53,6 @@ var ast = options.parse(tokens, options);

load.file = function loadFile(filename, options) {
load.validateOptions(options);
options.filename = filename;
var str = (options.read || load.read)(filename);
options = assign(getOptions(options), {
filename: filename
});
var str = options.read(filename);
return load.string(str, options);

@@ -78,14 +78,19 @@ }

load.validateOptions = function validateOptions(options) {
/* istanbul ignore if */
if (typeof options !== 'object') {
throw new TypeError('options must be an object');
}
/* istanbul ignore if */
if (typeof options.lex !== 'function') {
throw new TypeError('options.lex must be a function');
}
/* istanbul ignore if */
if (typeof options.parse !== 'function') {
throw new TypeError('options.parse must be a function');
}
/* istanbul ignore if */
if (options.resolve && typeof options.resolve !== 'function') {
throw new TypeError('options.resolve must be a function');
}
/* istanbul ignore if */
if (options.read && typeof options.read !== 'function') {

@@ -95,1 +100,9 @@ throw new TypeError('options.read must be a function');

};
function getOptions(options) {
load.validateOptions(options);
return assign({
resolve: load.resolve,
read: load.read
}, options);
}
{
"name": "pug-load",
"version": "2.0.2",
"version": "2.0.3",
"description": "The Pug loader is responsible for loading the depenendencies of a given Pug file.",

@@ -9,2 +9,3 @@ "keywords": [

"dependencies": {
"object-assign": "^4.1.0",
"pug-walk": "^1.0.0"

@@ -14,6 +15,8 @@ },

"pug-lexer": "^2.0.0",
"pug-parser": "^2.0.0"
"pug-parser": "^2.0.0",
"istanbul": "*"
},
"scripts": {
"test": "node test"
"test": "node test",
"coverage": "istanbul cover test"
},

@@ -20,0 +23,0 @@ "repository": {

@@ -8,2 +8,3 @@ # pug-load

[![NPM version](https://img.shields.io/npm/v/pug-load.svg)](https://www.npmjs.org/package/pug-load)
[![Coverage Status](https://img.shields.io/codecov/c/github/pugjs/pug-load.svg)](https://codecov.io/gh/pugjs/pug-load)

@@ -10,0 +11,0 @@ ## Installation

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