Comparing version 2.0.12 to 3.0.0-canary-1
55
index.js
@@ -13,5 +13,9 @@ 'use strict'; | ||
ast = JSON.parse(JSON.stringify(ast)); | ||
return walk(ast, function (node) { | ||
return walk(ast, function(node) { | ||
if (node.str === undefined) { | ||
if (node.type === 'Include' || node.type === 'RawInclude' || node.type === 'Extends') { | ||
if ( | ||
node.type === 'Include' || | ||
node.type === 'RawInclude' || | ||
node.type === 'Extends' | ||
) { | ||
var file = node.file; | ||
@@ -21,7 +25,8 @@ if (file.type !== 'FileReference') { | ||
} | ||
var path, str; | ||
var path, str, raw; | ||
try { | ||
path = options.resolve(file.path, file.filename, options); | ||
file.fullPath = path; | ||
str = options.read(path, options); | ||
raw = options.read(path, options); | ||
str = raw.toString('utf8'); | ||
} catch (ex) { | ||
@@ -32,6 +37,10 @@ ex.message += '\n at ' + node.filename + ' line ' + node.line; | ||
file.str = str; | ||
file.raw = raw; | ||
if (node.type === 'Extends' || node.type === 'Include') { | ||
file.ast = load.string(str, assign({}, options, { | ||
filename: path | ||
})); | ||
file.ast = load.string( | ||
str, | ||
assign({}, options, { | ||
filename: path, | ||
}) | ||
); | ||
} | ||
@@ -45,3 +54,3 @@ } | ||
options = assign(getOptions(options), { | ||
src: src | ||
src: src, | ||
}); | ||
@@ -54,5 +63,5 @@ var tokens = options.lex(src, options); | ||
options = assign(getOptions(options), { | ||
filename: filename | ||
filename: filename, | ||
}); | ||
var str = options.read(filename); | ||
var str = options.read(filename).toString('utf8'); | ||
return load.string(str, options); | ||
@@ -64,8 +73,15 @@ }; | ||
if (filename[0] !== '/' && !source) | ||
throw new Error('the "filename" option is required to use includes and extends with "relative" paths'); | ||
throw new Error( | ||
'the "filename" option is required to use includes and extends with "relative" paths' | ||
); | ||
if (filename[0] === '/' && !options.basedir) | ||
throw new Error('the "basedir" option is required to use includes and extends with "absolute" paths'); | ||
throw new Error( | ||
'the "basedir" option is required to use includes and extends with "absolute" paths' | ||
); | ||
filename = path.join(filename[0] === '/' ? options.basedir : path.dirname(source.trim()), filename); | ||
filename = path.join( | ||
filename[0] === '/' ? options.basedir : path.dirname(source.trim()), | ||
filename | ||
); | ||
@@ -75,3 +91,3 @@ return filename; | ||
load.read = function read(filename, options) { | ||
return fs.readFileSync(filename, 'utf8'); | ||
return fs.readFileSync(filename); | ||
}; | ||
@@ -104,6 +120,9 @@ | ||
load.validateOptions(options); | ||
return assign({ | ||
resolve: load.resolve, | ||
read: load.read | ||
}, options); | ||
return assign( | ||
{ | ||
resolve: load.resolve, | ||
read: load.read, | ||
}, | ||
options | ||
); | ||
} |
{ | ||
"name": "pug-load", | ||
"version": "2.0.12", | ||
"version": "3.0.0-canary-1", | ||
"description": "The Pug loader is responsible for loading the depenendencies of a given Pug file.", | ||
@@ -9,8 +9,8 @@ "keywords": [ | ||
"dependencies": { | ||
"object-assign": "^4.1.0", | ||
"pug-walk": "^1.1.8" | ||
"object-assign": "^4.1.1", | ||
"pug-walk": "2.0.0-canary-1" | ||
}, | ||
"devDependencies": { | ||
"pug-lexer": "^4.1.0", | ||
"pug-parser": "^5.0.1" | ||
"pug-lexer": "5.0.0-canary-1", | ||
"pug-parser": "6.0.0-canary-1" | ||
}, | ||
@@ -25,4 +25,3 @@ "files": [ | ||
"author": "ForbesLindesay", | ||
"license": "MIT", | ||
"gitHead": "1bdf628a70fda7a0d840c52f3abce54b1c6b0130" | ||
"license": "MIT" | ||
} |
@@ -55,3 +55,3 @@ # pug-load | ||
Callback used `pug-load` to ensure the options object is valid. If your overriden `load.resolve` or `load.read` uses a different `options` scheme, you will need to override this function as well. | ||
Callback used `pug-load` to ensure the options object is valid. If your overridden `load.resolve` or `load.read` uses a different `options` scheme, you will need to override this function as well. | ||
@@ -58,0 +58,0 @@ This function is not meant to be called from outside of `pug-load`, but rather for you to override. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
9366
111
2
1
+ Addedpug-walk@2.0.0-canary-1(transitive)
- Removedpug-walk@1.1.8(transitive)
Updatedobject-assign@^4.1.1
Updatedpug-walk@2.0.0-canary-1