Skip to content

Commit 3ee2e6d

Browse files
committed
Update debug.js version.
1 parent 4fb86d5 commit 3ee2e6d

2 files changed

Lines changed: 24 additions & 19 deletions

File tree

helpers/debug-raw.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@ const options = {};
1717
const isDebugging = process.argv.indexOf('debugging') !== -1;
1818
const directory = process.cwd();
1919
const path = require('path');
20-
const first = process.argv.indexOf('restart') === -1;
21-
const VERSION = '4.0';
20+
const VERSION = '5.0';
2221
const TIME = 2000;
22+
const REG_FILES = /config\-debug|config\-release|config|versions|sitemap|dependencies|\.js|\.resource/i;
23+
const REG_THEMES = /\/themes\//i;
24+
const REG_THEMES_INDEX = /themes(\/|\\)?[a-z0-9_.-]+(\/|\\)?index\.js/i;
25+
const REG_EXTENSION = /\.(js|resource|package)/i;
26+
27+
var first = process.argv.indexOf('restart') === -1;
2328

2429
process.on('uncaughtException', function(e) {
2530
e.toString().indexOf('ESRCH') == -1 && console.log(e);
2631
});
2732

2833
function 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

5257
function 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(/\/themes\//i))
72-
return path.match(/themes(\/|\\)?[a-z0-9_.-]+(\/|\\)?index\.js/gi) ? true : false;
73-
return isDirectory ? true : path.match(/\.(js|resource|package)/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(/config\-debug|config\-release|config|versions|sitemap|dependencies|\.js|\.resource/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);

helpers/debug.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)