create-require
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,2 +5,9 @@ # Changelog | ||
### [1.0.2](https://github.com/nuxt-contrib/create-require/compare/v1.0.1...v1.0.2) (2020-06-12) | ||
### Bug Fixes | ||
* use fake path if filename is directory ([c8e0983](https://github.com/nuxt-contrib/create-require/commit/c8e09834e322d8a106ac8018011f799e2fed03f2)) | ||
### [1.0.1](https://github.com/nuxt-contrib/create-require/compare/v1.0.0...v1.0.1) (2020-06-06) | ||
@@ -7,0 +14,0 @@ |
const nativeModule = require('module') | ||
const path = require('path') | ||
const fs = require('fs') | ||
function createRequire (filename) { | ||
// If filename is dir, createRequire goes with parent directory, so we need fakepath | ||
if (isDir(filename)) { | ||
filename = path.join(filename, 'index.js') | ||
} | ||
// Added in Node v12.2.0 | ||
@@ -28,2 +34,12 @@ if (nativeModule.createRequire) { | ||
function isDir (path) { | ||
try { | ||
const stat = fs.lstatSync(path) | ||
return stat.isDirectory() | ||
} catch (e) { | ||
// lstatSync throws an error if path doesn't exist | ||
return false | ||
} | ||
} | ||
module.exports = createRequire |
{ | ||
"name": "create-require", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Polyfill for Node.js module.createRequire (<= v12.2.0)", | ||
@@ -5,0 +5,0 @@ "repository": "nuxt-contrib/create-require", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
5509
38
3