pug-plugin-modules
Advanced tools
Comparing version 0.2.3 to 0.3.0
38
index.js
@@ -1,3 +0,3 @@ | ||
const path = require('path'); | ||
const resolve = require('resolve'); | ||
const path = require("path"); | ||
const resolve = require("resolve"); | ||
@@ -10,23 +10,35 @@ module.exports = function(options) { | ||
// Strip out extension that is automatically added by Pug | ||
file.ext = ''; | ||
file.ext = ""; | ||
file.base = file.name; | ||
let resolvePath; | ||
if (!file.dir && file.dir[0] !== path.sep && file.dir[0] !== '.') { | ||
let basedir = path.dirname(source); | ||
if (!file.dir && file.dir[0] !== path.sep && file.dir[0] !== ".") { | ||
resolvePath = file.name; | ||
} else { | ||
if (file.dir[0] === path.sep) { | ||
file.dir = `.${file.dir}`; | ||
file.root = `.${file.root}`; | ||
basedir = pugOptions.basedir; | ||
} | ||
resolvePath = path.format(file); | ||
} | ||
return resolve.sync(resolvePath, Object.assign({ | ||
basedir: path.dirname(source), | ||
extensions: ['.pug', '.jade'], | ||
packageFilter(pkg) { | ||
return Object.assign({}, pkg, { | ||
main: pkg.pug || pkg.main | ||
}); | ||
} | ||
}, options)); | ||
return resolve.sync( | ||
resolvePath, | ||
Object.assign( | ||
{ | ||
basedir, | ||
extensions: [".pug", ".jade"], | ||
packageFilter(pkg) { | ||
return Object.assign({}, pkg, { | ||
main: pkg.pug || pkg.main | ||
}); | ||
} | ||
}, | ||
options | ||
) | ||
); | ||
} | ||
}; | ||
}; |
{ | ||
"name": "pug-plugin-modules", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "Pug plugin for resolving templates in node_modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,1 +1,4 @@ | ||
[![npm](https://img.shields.io/npm/v/pug-plugin-modules.svg?style=flat-square)](https://www.npmjs.com/package/pug-plugin-modules) | ||
![npm](https://img.shields.io/npm/l/pug-plugin-modules.svg?style=flat-square) | ||
# pug-plugin-modules | ||
@@ -2,0 +5,0 @@ Pug plugin for resolving templates in node_modules |
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
4694
39
32