mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-01-25 14:42:47 +00:00
clear bootstrap files cache before load
This commit is contained in:
parent
639aae0aa8
commit
2f8a4b2070
10
src/index.js
10
src/index.js
@ -353,6 +353,16 @@ export default class {
|
||||
return;
|
||||
}
|
||||
let files = fs.readdirSync(item);
|
||||
|
||||
//must reload all bootstrap files.
|
||||
//may be register adapter in bootstrap file
|
||||
if (think.config('auto_reload')) {
|
||||
var AutoReload = require('./util/auto_reload.js');
|
||||
//AutoReload.rewriteSysModuleLoad();
|
||||
var instance = new AutoReload(item, () => {});
|
||||
instance.clearFilesCache(files.map(file => item + '/' + file));
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
let extname = path.extname(file);
|
||||
if(extname !== '.js'){
|
||||
|
||||
@ -6,6 +6,9 @@ import path from 'path';
|
||||
//can not use import from
|
||||
let sys_module = require('module');
|
||||
|
||||
//rewriteSysModuleLoad flag
|
||||
let _rewriteSysModuleLoad = false;
|
||||
|
||||
const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
|
||||
|
||||
/**
|
||||
@ -139,6 +142,12 @@ export default class extends think.base {
|
||||
* @return {} []
|
||||
*/
|
||||
static rewriteSysModuleLoad(){
|
||||
|
||||
if(_rewriteSysModuleLoad){
|
||||
return;
|
||||
}
|
||||
_rewriteSysModuleLoad = true;
|
||||
|
||||
let load = sys_module._load;
|
||||
|
||||
//rewrite Module._load method
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user