New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hot-reload

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hot-reload - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

lib/hot-reload/node-rest-handler.sublime-workspace

55

lib/hot-reload/hot-reload.js

@@ -9,2 +9,6 @@ // third-party dependencies

function resolveFilename(filename) {
if (filename.constructor !== String) {
return filename;
}
if ((filename.charAt(0) !== '.') && (filename.charAt(0) !== '/')) {

@@ -26,3 +30,3 @@ return filename;

this.include(config.include);
console.log('[Hot Reload] Watched directories: ' + JSON.stringify(this._includes));
console.log('[Hot Reload] Watched directories/files: ' + JSON.stringify(this._includes));
}

@@ -59,3 +63,3 @@

self.emit('beforeReload');
var reloadableModules = [];

@@ -68,3 +72,3 @@

if (self.isModuleReloadable(module)) {
console.log('[Hot Reload] Unloading ' + module.filename);
//console.log('[Hot Reload] Unloading ' + module.filename);
// delete the cache entry only in first pass

@@ -75,5 +79,9 @@ delete require.cache[key];

reloadableModules.push(module);
} else {
//console.log('[Hot Reload] Not unloading ' + module.filename);
}
}
console.log('[Hot Reload] ' + reloadableModules.length + ' modules removed from cache.');
if (!config || (config.autoReload !== false)) {

@@ -95,2 +103,16 @@ // SECOND PASS: Now trigger a reload of all of the modules since their cache entry was removed

function matches(filter, name) {
if (filter.constructor === RegExp) {
// see if name matches regex
if (filter.test(name)) {
return true;
}
} else {
// see if name starts with given filter value
if (name.indexOf(filter) === 0) {
return true;
}
}
}
HotReloader.prototype.isModuleReloadable = function(module) {

@@ -103,3 +125,3 @@

var exclude = this._excludes[i];
if (filename.indexOf(exclude) === 0) {
if (matches(exclude, filename)) {
return false;

@@ -113,3 +135,3 @@ }

var exclude = this._neverReload[i];
if (filename.indexOf(exclude) === 0) {
if (matches(exclude, filename)) {
return false;

@@ -123,3 +145,3 @@ }

var include = this._alwaysReload[i];
if (filename.indexOf(include) === 0) {
if (matches(include, filename)) {
return true;

@@ -133,3 +155,3 @@ }

var include = this._includes[i];
if (filename.indexOf(include) === 0) {
if (matches(include, filename)) {
return true;

@@ -158,2 +180,3 @@ }

delete require.cache[module.filename];
var newModule = require(module.filename);

@@ -168,3 +191,3 @@

}
this.emit('afterModuleReload', module);

@@ -188,3 +211,4 @@ }

* for changes. Also, all Node.js modules within these directories
* will automatically be reloaded if a file is changed.
* will automatically be reloaded if a file is changed
* (unless they are explicitly excluded).
*/

@@ -252,3 +276,3 @@ HotReloader.prototype.include = function(includes) {

// store the file path of the modulePaths that should always be reloaded
// store the file path of the modulePaths that should never be reloaded
this._neverReload.push(resolveFilename(modulePath));

@@ -267,11 +291,2 @@ }

onFile : function(file) {
console.log('[Hot Reload] Watching file: ' + file);
fs.watch(file,
function(event, changedFile) {
console.log('[Hot Reload] File changed: ' + (changedFile || file));
self._scheduleReload();
});
},
onDirectory : function(directory) {

@@ -281,3 +296,3 @@ console.log('[Hot Reload] Watching directory: ' + directory);

function(event, file) {
console.log('[Hot Reload] Directory changed: ' + file);
console.log('[Hot Reload] Changed: ' + file);
self._scheduleReload();

@@ -284,0 +299,0 @@ });

{
"name": "hot-reload",
"description": "Triggers reloading of Node.js modules",
"version": "1.1.0",
"version": "1.2.0",
"homepage": "https://github.com/philidem/node-hot-reload",

@@ -14,4 +14,4 @@ "authors": [

"dependencies": {
"directory-walker" : "1.1.0"
"directory-walker" : "1.2.x"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc