update modules
This commit is contained in:
172
node_modules/ejs/ejs.js
generated
vendored
172
node_modules/ejs/ejs.js
generated
vendored
@@ -50,6 +50,7 @@ var path = require('path');
|
||||
var utils = require('./utils');
|
||||
|
||||
var scopeOptionWarned = false;
|
||||
/** @type {string} */
|
||||
var _VERSION_STRING = require('../package.json').version;
|
||||
var _DEFAULT_OPEN_DELIMITER = '<';
|
||||
var _DEFAULT_CLOSE_DELIMITER = '>';
|
||||
@@ -100,7 +101,7 @@ exports.localsName = _DEFAULT_LOCALS_NAME;
|
||||
* Promise implementation -- defaults to the native implementation if available
|
||||
* This is mostly just for testability
|
||||
*
|
||||
* @type {Function}
|
||||
* @type {PromiseConstructorLike}
|
||||
* @public
|
||||
*/
|
||||
|
||||
@@ -112,7 +113,7 @@ exports.promiseImpl = (new Function('return this;'))().Promise;
|
||||
*
|
||||
* @param {String} name specified path
|
||||
* @param {String} filename parent file path
|
||||
* @param {Boolean} isDir parent file path whether is directory
|
||||
* @param {Boolean} [isDir=false] whether the parent file path is a directory
|
||||
* @return {String}
|
||||
*/
|
||||
exports.resolveInclude = function(name, filename, isDir) {
|
||||
@@ -127,6 +128,23 @@ exports.resolveInclude = function(name, filename, isDir) {
|
||||
return includePath;
|
||||
};
|
||||
|
||||
/**
|
||||
* Try to resolve file path on multiple directories
|
||||
*
|
||||
* @param {String} name specified path
|
||||
* @param {Array<String>} paths list of possible parent directory paths
|
||||
* @return {String}
|
||||
*/
|
||||
function resolvePaths(name, paths) {
|
||||
var filePath;
|
||||
if (paths.some(function (v) {
|
||||
filePath = exports.resolveInclude(name, v, true);
|
||||
return fs.existsSync(filePath);
|
||||
})) {
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the included file by Options
|
||||
*
|
||||
@@ -142,7 +160,12 @@ function getIncludePath(path, options) {
|
||||
|
||||
// Abs path
|
||||
if (match && match.length) {
|
||||
includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
|
||||
path = path.replace(/^\/*/, '');
|
||||
if (Array.isArray(options.root)) {
|
||||
includePath = resolvePaths(path, options.root);
|
||||
} else {
|
||||
includePath = exports.resolveInclude(path, options.root || '/', true);
|
||||
}
|
||||
}
|
||||
// Relative paths
|
||||
else {
|
||||
@@ -154,15 +177,10 @@ function getIncludePath(path, options) {
|
||||
}
|
||||
}
|
||||
// Then look in any views directories
|
||||
if (!includePath) {
|
||||
if (Array.isArray(views) && views.some(function (v) {
|
||||
filePath = exports.resolveInclude(path, v, true);
|
||||
return fs.existsSync(filePath);
|
||||
})) {
|
||||
includePath = filePath;
|
||||
}
|
||||
if (!includePath && Array.isArray(views)) {
|
||||
includePath = resolvePaths(path, views);
|
||||
}
|
||||
if (!includePath) {
|
||||
if (!includePath && typeof options.includer !== 'function') {
|
||||
throw new Error('Could not find the include file "' +
|
||||
options.escapeFunction(path) + '"');
|
||||
}
|
||||
@@ -290,53 +308,39 @@ function fileLoader(filePath){
|
||||
function includeFile(path, options) {
|
||||
var opts = utils.shallowCopy({}, options);
|
||||
opts.filename = getIncludePath(path, opts);
|
||||
if (typeof options.includer === 'function') {
|
||||
var includerResult = options.includer(path, opts.filename);
|
||||
if (includerResult) {
|
||||
if (includerResult.filename) {
|
||||
opts.filename = includerResult.filename;
|
||||
}
|
||||
if (includerResult.template) {
|
||||
return handleCache(opts, includerResult.template);
|
||||
}
|
||||
}
|
||||
}
|
||||
return handleCache(opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JavaScript source of an included file.
|
||||
*
|
||||
* @memberof module:ejs-internal
|
||||
* @param {String} path path for the specified file
|
||||
* @param {Options} options compilation options
|
||||
* @return {Object}
|
||||
* @static
|
||||
*/
|
||||
|
||||
function includeSource(path, options) {
|
||||
var opts = utils.shallowCopy({}, options);
|
||||
var includePath;
|
||||
var template;
|
||||
includePath = getIncludePath(path, opts);
|
||||
template = fileLoader(includePath).toString().replace(_BOM, '');
|
||||
opts.filename = includePath;
|
||||
var templ = new Template(template, opts);
|
||||
templ.generateSource();
|
||||
return {
|
||||
source: templ.source,
|
||||
filename: includePath,
|
||||
template: template
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
||||
* `lineno`.
|
||||
*
|
||||
* @implements RethrowCallback
|
||||
* @implements {RethrowCallback}
|
||||
* @memberof module:ejs-internal
|
||||
* @param {Error} err Error object
|
||||
* @param {String} str EJS source
|
||||
* @param {String} filename file name of the EJS file
|
||||
* @param {String} lineno line number of the error
|
||||
* @param {String} flnm file name of the EJS file
|
||||
* @param {Number} lineno line number of the error
|
||||
* @param {EscapeCallback} esc
|
||||
* @static
|
||||
*/
|
||||
|
||||
function rethrow(err, str, flnm, lineno, esc){
|
||||
function rethrow(err, str, flnm, lineno, esc) {
|
||||
var lines = str.split('\n');
|
||||
var start = Math.max(lineno - 3, 0);
|
||||
var end = Math.min(lines.length, lineno + 3);
|
||||
var filename = esc(flnm); // eslint-disable-line
|
||||
var filename = esc(flnm);
|
||||
// Error context
|
||||
var context = lines.slice(start, end).map(function (line, i){
|
||||
var curr = i + start + 1;
|
||||
@@ -365,7 +369,7 @@ function stripSemi(str){
|
||||
*
|
||||
* @param {String} template EJS template
|
||||
*
|
||||
* @param {Options} opts compilation options
|
||||
* @param {Options} [opts] compilation options
|
||||
*
|
||||
* @return {(TemplateFunction|ClientFunction)}
|
||||
* Depending on the value of `opts.client`, either type might be returned.
|
||||
@@ -505,11 +509,11 @@ function Template(text, opts) {
|
||||
opts = opts || {};
|
||||
var options = {};
|
||||
this.templateText = text;
|
||||
/** @type {string | null} */
|
||||
this.mode = null;
|
||||
this.truncate = false;
|
||||
this.currentLine = 1;
|
||||
this.source = '';
|
||||
this.dependencies = [];
|
||||
options.client = opts.client || false;
|
||||
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
||||
options.compileDebug = opts.compileDebug !== false;
|
||||
@@ -523,6 +527,7 @@ function Template(text, opts) {
|
||||
options.cache = opts.cache || false;
|
||||
options.rmWhitespace = opts.rmWhitespace;
|
||||
options.root = opts.root;
|
||||
options.includer = opts.includer;
|
||||
options.outputFunctionName = opts.outputFunctionName;
|
||||
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
||||
options.views = opts.views;
|
||||
@@ -563,12 +568,16 @@ Template.prototype = {
|
||||
},
|
||||
|
||||
compile: function () {
|
||||
/** @type {string} */
|
||||
var src;
|
||||
/** @type {ClientFunction} */
|
||||
var fn;
|
||||
var opts = this.opts;
|
||||
var prepended = '';
|
||||
var appended = '';
|
||||
/** @type {EscapeCallback} */
|
||||
var escapeFn = opts.escapeFunction;
|
||||
/** @type {FunctionConstructor} */
|
||||
var ctor;
|
||||
|
||||
if (!this.source) {
|
||||
@@ -682,7 +691,6 @@ Template.prototype = {
|
||||
};
|
||||
return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
|
||||
};
|
||||
returnedFn.dependencies = this.dependencies;
|
||||
if (opts.filename && typeof Object.defineProperty === 'function') {
|
||||
var filename = opts.filename;
|
||||
var basename = path.basename(filename, path.extname(filename));
|
||||
@@ -720,12 +728,7 @@ Template.prototype = {
|
||||
|
||||
if (matches && matches.length) {
|
||||
matches.forEach(function (line, index) {
|
||||
var opening;
|
||||
var closing;
|
||||
var include;
|
||||
var includeOpts;
|
||||
var includeObj;
|
||||
var includeSrc;
|
||||
// If this is an opening tag, check for closing tags
|
||||
// FIXME: May end up with some false positives here
|
||||
// Better to store modes as k/v with openDelimiter + delimiter as key
|
||||
@@ -737,35 +740,6 @@ Template.prototype = {
|
||||
throw new Error('Could not find matching close tag for "' + line + '".');
|
||||
}
|
||||
}
|
||||
// HACK: backward-compat `include` preprocessor directives
|
||||
if (opts.legacyInclude && (include = line.match(/^\s*include\s+(\S+)/))) {
|
||||
opening = matches[index - 1];
|
||||
// Must be in EVAL or RAW mode
|
||||
if (opening && (opening == o + d || opening == o + d + '-' || opening == o + d + '_')) {
|
||||
includeOpts = utils.shallowCopy({}, self.opts);
|
||||
includeObj = includeSource(include[1], includeOpts);
|
||||
if (self.opts.compileDebug) {
|
||||
includeSrc =
|
||||
' ; (function(){' + '\n'
|
||||
+ ' var __line = 1' + '\n'
|
||||
+ ' , __lines = ' + JSON.stringify(includeObj.template) + '\n'
|
||||
+ ' , __filename = ' + JSON.stringify(includeObj.filename) + ';' + '\n'
|
||||
+ ' try {' + '\n'
|
||||
+ includeObj.source
|
||||
+ ' } catch (e) {' + '\n'
|
||||
+ ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
|
||||
+ ' }' + '\n'
|
||||
+ ' ; }).call(this)' + '\n';
|
||||
}else{
|
||||
includeSrc = ' ; (function(){' + '\n' + includeObj.source +
|
||||
' ; }).call(this)' + '\n';
|
||||
}
|
||||
self.source += includeSrc;
|
||||
self.dependencies.push(exports.resolveInclude(include[1],
|
||||
includeOpts.filename));
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.scanLine(line);
|
||||
});
|
||||
}
|
||||
@@ -939,22 +913,6 @@ exports.escapeXML = utils.escapeXML;
|
||||
|
||||
exports.__express = exports.renderFile;
|
||||
|
||||
// Add require support
|
||||
/* istanbul ignore else */
|
||||
if (require.extensions) {
|
||||
require.extensions['.ejs'] = function (module, flnm) {
|
||||
console.log('Deprecated: this API will go away in EJS v2.8');
|
||||
var filename = flnm || /* istanbul ignore next */ module.filename;
|
||||
var options = {
|
||||
filename: filename,
|
||||
client: true
|
||||
};
|
||||
var template = fileLoader(filename).toString();
|
||||
var fn = exports.compile(template, options);
|
||||
module._compile('module.exports = ' + fn.toString() + ';', filename);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of EJS.
|
||||
*
|
||||
@@ -1129,7 +1087,7 @@ exports.shallowCopyFromList = function (to, from, list) {
|
||||
* Simple in-process cache implementation. Does not implement limits of any
|
||||
* sort.
|
||||
*
|
||||
* @implements Cache
|
||||
* @implements {Cache}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
@@ -1652,25 +1610,31 @@ module.exports={
|
||||
"engine",
|
||||
"ejs"
|
||||
],
|
||||
"version": "2.7.4",
|
||||
"version": "3.1.3",
|
||||
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"ejs": "./bin/cli.js"
|
||||
},
|
||||
"main": "./lib/ejs.js",
|
||||
"jsdelivr": "ejs.min.js",
|
||||
"unpkg": "ejs.min.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mde/ejs.git"
|
||||
},
|
||||
"bugs": "https://github.com/mde/ejs/issues",
|
||||
"homepage": "https://github.com/mde/ejs",
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"jake": "^10.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^13.1.1",
|
||||
"eslint": "^4.14.0",
|
||||
"browserify": "^16.5.1",
|
||||
"eslint": "^6.8.0",
|
||||
"git-directory-deploy": "^1.5.1",
|
||||
"jake": "^10.3.1",
|
||||
"jsdoc": "^3.4.0",
|
||||
"jsdoc": "^3.6.4",
|
||||
"lru-cache": "^4.0.1",
|
||||
"mocha": "^5.0.5",
|
||||
"mocha": "^7.1.1",
|
||||
"uglify-js": "^3.3.16"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1678,7 +1642,7 @@ module.exports={
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"postinstall": "node ./postinstall.js"
|
||||
"postinstall": "node --harmony ./postinstall.js"
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user