forked from Grepsy/hotrequire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
20 lines (15 loc) · 723 Bytes
/
test.js
File metadata and controls
20 lines (15 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var hotrequire = require('./hotrequire.js');
var example = require.hot('./examplemodule.js', function(module) {
example = module;
});
console.log(example.message); // Outputs the message of the module
process.on('modified', function(file) { // Debug information
console.log('['+new Date()+': '+file+' reloaded]');
});
process.on('removed', function(file) { // Debug information
console.log('['+new Date()+': '+file+' was removed, stop observing]'); // To force this message simply rename the example.js to whatever you want.
});
var self = this;
process.on('reloaded', function(file) { // Debug information
console.log(example.message); // Will output the new message of the module (after you have changed it)
});