@@ -17,16 +17,21 @@ const options = {};
1717const isDebugging = process . argv . indexOf ( 'debugging' ) !== - 1 ;
1818const directory = process . cwd ( ) ;
1919const path = require ( 'path' ) ;
20- const first = process . argv . indexOf ( 'restart' ) === - 1 ;
21- const VERSION = '4.0' ;
20+ const VERSION = '5.0' ;
2221const TIME = 2000 ;
22+ const REG_FILES = / c o n f i g \- d e b u g | c o n f i g \- r e l e a s e | c o n f i g | v e r s i o n s | s i t e m a p | d e p e n d e n c i e s | \. j s | \. r e s o u r c e / i;
23+ const REG_THEMES = / \/ t h e m e s \/ / i;
24+ const REG_THEMES_INDEX = / t h e m e s ( \/ | \\ ) ? [ a - z 0 - 9 _ . - ] + ( \/ | \\ ) ? i n d e x \. j s / i;
25+ const REG_EXTENSION = / \. ( j s | r e s o u r c e | p a c k a g e ) / i;
26+
27+ var first = process . argv . indexOf ( 'restart' ) === - 1 ;
2328
2429process . on ( 'uncaughtException' , function ( e ) {
2530 e . toString ( ) . indexOf ( 'ESRCH' ) == - 1 && console . log ( e ) ;
2631} ) ;
2732
2833function debug ( ) {
29- var framework = require ( 'total.js' ) ;
34+ require ( 'total.js' ) ;
3035 var port = parseInt ( process . argv [ process . argv . length - 1 ] ) ;
3136
3237 if ( ! isNaN ( port ) ) {
@@ -39,38 +44,38 @@ function debug() {
3944 options . port = port || 8000 ;
4045
4146 if ( options . https )
42- return framework . https ( 'debug' , options ) ;
47+ return F . https ( 'debug' , options ) ;
4348
44- framework . http ( 'debug' , options ) ;
49+ F . http ( 'debug' , options ) ;
4550
4651 if ( first )
47- framework . emit ( 'debug-start' ) ;
52+ F . emit ( 'debug-start' ) ;
4853 else
49- framework . emit ( 'debug-restart' ) ;
54+ F . emit ( 'debug-restart' ) ;
5055}
5156
5257function app ( ) {
53- var fork = require ( 'child_process' ) . fork ;
54- var utils = require ( 'total.js/utils' ) ;
55- var directories = [ directory + '/controllers' , directory + '/definitions' , directory + '/isomorphic' , directory + '/modules' , directory + '/resources' , directory + '/models' , directory + '/source' , directory + '/workers' , directory + '/packages' , directory + '/themes' ] ;
58+ const fork = require ( 'child_process' ) . fork ;
59+ const utils = require ( 'total.js/utils' ) ;
60+ const directories = [ directory + '/controllers' , directory + '/definitions' , directory + '/isomorphic' , directory + '/modules' , directory + '/resources' , directory + '/models' , directory + '/source' , directory + '/workers' , directory + '/packages' , directory + '/themes' ] ;
61+ const async = new utils . Async ( ) ;
62+ const prefix = '----------------------------------------------------> ' ;
5663 var files = { } ;
5764 var force = false ;
5865 var changes = [ ] ;
5966 var app = null ;
6067 var status = 0 ;
61- var async = new utils . Async ( ) ;
6268 var pid = '' ;
6369 var pidInterval = null ;
64- var prefix = '----------------------------------------------------> ' ;
6570 var isLoaded = false ;
6671 var isSkip = false ;
6772 var pidIncrease ;
6873 var speed = TIME ;
6974
7075 function onFilter ( path , isDirectory ) {
71- if ( ! isDirectory && path . match ( / \/ t h e m e s \/ / i ) )
72- return path . match ( / t h e m e s ( \/ | \\ ) ? [ a - z 0 - 9 _ . - ] + ( \/ | \\ ) ? i n d e x \. j s / gi ) ? true : false ;
73- return isDirectory ? true : path . match ( / \. ( j s | r e s o u r c e | p a c k a g e ) / i ) !== null ;
76+ if ( ! isDirectory && REG_THEMES . test ( path ) )
77+ return REG_THEMES_INDEX . test ( path ) ;
78+ return isDirectory ? true : REG_EXTENSION . test ( path ) ;
7479 }
7580
7681 function onIncrease ( clear ) {
@@ -96,7 +101,7 @@ function app() {
96101
97102 for ( var i = 0 ; i < length ; i ++ ) {
98103 var name = arr [ i ] ;
99- name !== 'debug.js' && name . match ( / c o n f i g \- d e b u g | c o n f i g \- r e l e a s e | c o n f i g | v e r s i o n s | s i t e m a p | d e p e n d e n c i e s | \. j s | \. r e s o u r c e / i ) && f . push ( name ) ;
104+ name !== 'debug.js' && REG_FILES . test ( name ) && f . push ( name ) ;
100105 }
101106
102107 length = f . length ;
@@ -250,9 +255,9 @@ function app() {
250255 fs . writeFileSync ( pid , process . pid ) ;
251256
252257 pidInterval = setInterval ( function ( ) {
253- fs . exists ( pid , function ( exist ) {
258+ fs . exists ( pid , function ( e ) {
254259
255- if ( exist )
260+ if ( e )
256261 return ;
257262
258263 fs . unlink ( pid , noop ) ;
0 commit comments