diff --git a/bin/index.coffee b/bin/index.coffee index 2844a6d..ce55e61 100755 --- a/bin/index.coffee +++ b/bin/index.coffee @@ -6,7 +6,6 @@ _path = require('path') _forever = require 'forever-monitor' _os = require 'os' _ = require 'lodash' -_livereload = require 'livereload' require 'colors' _initialize = require '../lib/initialize' @@ -40,20 +39,6 @@ init = (ops, loadPlugin)-> #初始化插件模块 require('../lib/plugin').init() if loadPlugin -#初始化livereload -initLivereload = ()-> - options = _utils.xPathMapValue('livereload', _utils.config) - - return if not options - ops = { - exts: ['less', 'coffee', 'hbs', 'html', 'css', 'js', 'htm', 'handlebars', 'scss'] - } - _.extend ops, options - - #启动livereload服务 - llServer = _livereload.createServer(ops) - llServer.watch _utils.options.workbench - #######################################插件相关######################################### #安装插件的命令 _program.command('install [names...]') @@ -264,8 +249,6 @@ _program silky = require '../lib/index' silky(app, server, true) - initLivereload() - # #暂时放弃forever的方式 # if true or _os.platform() is 'win32' # global.SILKY = options diff --git a/lib/router.coffee b/lib/router.coffee index 4e05283..0846e11 100644 --- a/lib/router.coffee +++ b/lib/router.coffee @@ -14,20 +14,8 @@ _hooks = require './plugin/hooks' _utils = require './utils' _compiler = require './compiler' -#如果文件存在,则直接响应这个文件 -responseFileIfExists = (file, res)-> - #如果html文件存在,则直接输出 - if _fs.existsSync file - res.sendfile file - return true - #响应纯内容数据 responseContent = (content, mime, req, res, next)-> - #如果是html,则考虑要在head前加入livereload - if _utils.config.livereload and _mime.extension(mime) is 'html' - script = " \n$1" - content = content.replace /(<\/\s*head>)/i, script - data = content: content mime: mime @@ -45,8 +33,11 @@ responseContent = (content, mime, req, res, next)-> #统一处理响应 response = (route, options, req, res, next)-> #对于css/html/js,先检查文件是否存在,如果文件存在,则直接返回 - return if /\.(html|htm|js|css|coffee)$/i.test(route.realpath) and responseFileIfExists(route.realpath, res) - + if /\.(html|htm|js|css|coffee)$/i.test(route.realpath) and _fs.existsSync route.realpath + content = _fs.readFileSync(route.realpath, {encoding: 'utf8'}) + responseContent content, route.mime, req, res, next + return + # #查找真实的未编译源文件路径 # sourceFile = _compiler.sourceFile(route.compiler, route.realpath) # #没有找到对应的源文件,这是一个404错误 @@ -289,4 +280,4 @@ module.exports = (app)-> options = pluginData: data.pluginData - response data.route, options, req, res, next \ No newline at end of file + response data.route, options, req, res, next diff --git a/lib/utils.coffee b/lib/utils.coffee index ae044f5..32f582b 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -150,7 +150,6 @@ exports.init = (options)-> env: 'development' workbench: null buildMode: false - livereload: 'http://localhost:35729/livereload.js' _.merge _options, options _options.identity = '.silky' diff --git a/package.json b/package.json index 5205477..6cb90e7 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "json-literal": "^1.1.0", "json-proxy": "^0.3.1", "less": "1.7.3", - "livereload": "^0.3.7", "lodash": "^2.4.1", "mime": "^1.2.11", "mkdirp": "*",