Permalink
Browse files

修复命令行运行dobby时寻址的bug

  • Loading branch information...
deemstone
deemstone committed Feb 25, 2013
1 parent a8ec477 commit 4a5c2b270ed4785453fc63b028a0194c24be0c5d
Showing with 9 additions and 4 deletions.
  1. +3 −2 watcher.js
  2. +6 −2 watcher.md
View
@@ -11,13 +11,14 @@ var exec = require('child_process').exec;
var fsx = require('fs-extra');
//用命令行第一个参数指定工程目录
-var project_path = (__filename == process.argv[1]) ? process.argv[2] : process.argv[1]; //如果直接node watcher.js方式运行的argv[0]是node
+//console.log(__filename, process.argv, process.env);
+var project_path = process.argv[2]; //argv[0]是node
//project_path = path.resolve(__dirname, project_path);//
var project_config;
//读取工程下的wc.json配置文件
try{
- project_config = require(project_path +'/wc.json');
+ project_config = require( path.resolve(project_path +'/wc.json') ); //由于require寻址方式,这里需要提供完整路径,resolve一下
}catch(e){
console.error('\n貌似你的工程下wc.json配置文件有问题... ~_- \n');
console.error(e.stack);
View
@@ -13,7 +13,7 @@ Dobby终极目标:
本期功能设计:
-----------
-命令行程序,在终端运行,指定js工程目录,读取配置文件监视文件改动自动发布到build目录
+命令行程序,在终端运行,指定js工程目录,读取配置文件监视文件改动自动copy到指定目录
```
$ dobby /path/to/project
@@ -38,4 +38,8 @@ $ dobby /path/to/project
1. git clone ...
2. git checkout wc
3. npm install -g
-4. 可以使用dobby命令了
+4. 可以使用dobby命令了
+
+细节:
+
+目前watcher的实现,使用fs.watch这个接口,文件的任何改动都会检测到,即使是没有任何改动单纯的cmd+s保存也会触发copy。

0 comments on commit 4a5c2b2

Please sign in to comment.