| 80 | } |
| 81 | |
| 82 | function runwatching() { |
| 83 | |
| 84 | !options && (options = {}); |
| 85 | require('./index'); |
| 86 | |
| 87 | const FILENAME = U.getName(process.argv[1] || 'debug.js'); |
| 88 | const directory = process.cwd(); |
| 89 | const VERSION = F.version_header; |
| 90 | const REG_CONFIGS = /configs\//g; |
| 91 | const REG_FILES = /config-debug|config-release|config|versions|workflows|sitemap|dependencies|\.js$|\.resource$/i; |
| 92 | const REG_THEMES = /\/themes\//i; |
| 93 | const REG_PUBLIC = /\/public\//i; |
| 94 | const REG_COMPONENTS = /components\/.*?\.html|\.package\/.*?$/i; |
| 95 | const REG_THEMES_INDEX = /themes(\/|\\)?[a-z0-9_.-]+(\/|\\)?index\.js$/i; |
| 96 | const REG_EXTENSION = /\.(js|resource|package|bundle)$/i; |
| 97 | const REG_RELOAD = /\.(js|css|html|htm|jpg|png|gif|ico|svg|resource)$/i; |
| 98 | const isRELOAD = !!options.livereload; |
| 99 | const SPEED = isRELOAD ? 1000 : 1500; |
| 100 | const ARGV = CLONE(process.argv); |
| 101 | const PIDNAME = FILENAME.replace(/\.js$/, '.pid'); |
| 102 | |
| 103 | function copyFile(oldname, newname, callback) { |
| 104 | var writer = Fs.createWriteStream(newname); |
| 105 | callback && writer.on('finish', callback); |
| 106 | Fs.createReadStream(oldname).pipe(writer); |
| 107 | } |
| 108 | |
| 109 | function app() { |
| 110 | |
| 111 | if (!watchercallback) { |
| 112 | global.OBSOLETE = NOOP; |
| 113 | F.config.allow_ssc_validation = true; |
| 114 | F.$configure_configs(); |
| 115 | } |
| 116 | |
| 117 | F.directory = directory; |
| 118 | |
| 119 | const fork = require('child_process').fork; |
| 120 | const directories = [ |
| 121 | U.combine(CONF.directory_components), |
| 122 | U.combine(CONF.directory_controllers), |
| 123 | U.combine(CONF.directory_definitions), |
| 124 | U.combine(CONF.directory_operations), |
| 125 | U.combine(CONF.directory_isomorphic), |
| 126 | U.combine(CONF.directory_modules), |
| 127 | U.combine(CONF.directory_models), |
| 128 | U.combine(CONF.directory_schemas), |
| 129 | U.combine(CONF.directory_tasks), |
| 130 | U.combine(CONF.directory_resources), |
| 131 | U.combine(CONF.directory_source), |
| 132 | U.combine(CONF.directory_workers), |
| 133 | U.combine(CONF.directory_packages), |
| 134 | U.combine(CONF.directory_themes), |
| 135 | U.combine(CONF.directory_configs), |
| 136 | U.combine(CONF.directory_bundles), |
| 137 | U.combine('/startup/'), |
| 138 | U.combine('/plugins/') |
| 139 | ]; |