New:Socket for Asana Is Now Available.Learn more
Get Started

clear-module

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-module - npm Package Compare versions

Comparing version
3.2.0
to
4.0.0
+23
-2
index.js

@@ -6,2 +6,10 @@ 'use strict';

const resolve = moduleId => {
try {
return resolveFrom(path.dirname(parentModule(__filename)), moduleId);
} catch (error) {
return undefined;
}
};
const clear = moduleId => {

@@ -12,4 +20,8 @@ if (typeof moduleId !== 'string') {

const filePath = resolveFrom(path.dirname(parentModule(__filename)), moduleId);
const filePath = resolve(moduleId);
if (!filePath) {
return;
}
// Delete itself from module parent

@@ -26,2 +38,9 @@ if (require.cache[filePath] && require.cache[filePath].parent) {

// Remove all descendants from cache as well
if (require.cache[filePath]) {
for (const {id} of require.cache[filePath].children) {
clear(id);
}
}
// Delete module from cache

@@ -32,4 +51,6 @@ delete require.cache[filePath];

clear.all = () => {
const directory = path.dirname(parentModule(__filename));
for (const moduleId of Object.keys(require.cache)) {
clear(moduleId);
delete require.cache[resolveFrom(directory, moduleId)];
}

@@ -36,0 +57,0 @@ };

+7
-7
{
"name": "clear-module",
"version": "3.2.0",
"version": "4.0.0",
"description": "Clear a module from the cache",

@@ -13,3 +13,3 @@ "license": "MIT",

"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -34,12 +34,12 @@ "scripts": {

"delete",
"del",
"remove",
"rm"
"rm",
"fresh"
],
"dependencies": {
"parent-module": "^1.0.1",
"resolve-from": "^4.0.0"
"parent-module": "^2.0.0",
"resolve-from": "^5.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"ava": "^2.1.0",
"tsd": "^0.7.2",

@@ -46,0 +46,0 @@ "xo": "^0.24.0"

@@ -70,6 +70,1 @@ # clear-module [![Build Status](https://travis-ci.org/sindresorhus/clear-module.svg?branch=master)](https://travis-ci.org/sindresorhus/clear-module)

- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)