Skip to content

Commit

Permalink
为第一次发布到npm做改动
Browse files Browse the repository at this point in the history
配置目录只使用~/.dproxy弃用程序目录下的conf
setting中添加判断.dproxy是否存在,自动拷贝conf目录内容创建.dproxy
判断dproxy.conf文件是否存在,提示用户创建配置
修改package.json支持npm install -g
  • Loading branch information
deemstone committed Feb 20, 2013
1 parent f3ef0da commit 0160528
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/*
* dproxy的一个命令行启动器
* 可以手动运行这个程序(./fun/dproxy-cli.js的一个替身)
*/

require('./fun/dproxy-cli.js');
require('./fun/dproxy-cli.js');
2 changes: 1 addition & 1 deletion fun/dproxy-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ try{
//把所有没处理的异常信息记录在文件里
var fs = require('fs');
var path = require('path');
var dir_log = paths.base +'/log';
var dir_log = paths.conf +'/log'; //如果全局安装--gloabl,普通用户运行权限无法操作basedir下的文件,所以改到.dproxy下存放log
if( !path.existsSync( dir_log ) ){
fs.mkdirSync( dir_log );
}
Expand Down
25 changes: 17 additions & 8 deletions fun/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,25 @@ if(options.config){
}else{
//查看$HOME/.dproxy是否存在;从这里查找配置文件
var home_dproxy = path.resolve(process.env['HOME'] + '/.dproxy');
//如果还没有.dproxy就mkdir一个新的
if( !path.existsSync(home_dproxy) ){
require('child_process').exec('cp -R '+ paths.base +'/conf ~/.dproxy');
}
var filepath = path.resolve(home_dproxy +'/dproxy.conf');
if(path.existsSync(filepath) ){ //path.existsSync( home_dproxy) &&
paths.conf = home_dproxy;
cfilepath = filepath;
//接着判断这目录下面是否有个rule目录
var home_rule = path.resolve(home_dproxy + '/rule');
//if(path.existsSync( home_rule) ){
paths.rule = home_rule;
//}
if( !path.existsSync(filepath) ){
console.info();
console.info('第一次使用,先看一下~/.dproxy目录');
console.info('用sample创建一个dproxy.conf文件');
console.info();
console.info(' ^_^');
console.info();
process.exit(1);
}
paths.conf = home_dproxy;
cfilepath = filepath;
//接着判断这目录下面是否有个rule目录
var home_rule = path.resolve(home_dproxy + '/rule');
paths.rule = home_rule;
}

//读取指定配置文件的内容,解析成键值对象
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"web debug",
"proxy"
],
"version": "0.7",
"version": "0.7.1",
"homepage": "http://github.com/deemstone/Dproxy",
"author": "Deemstone Li <deemstone@gmail.com> (http://blog.cooer.net)",
"repository": {
Expand All @@ -22,8 +22,7 @@
"lib": "./lib",
"bin": "./bin"
},
"main": "./fun/dproxy-cli.js",
"bin": "./fun/dproxy-cli.js",
"bin": "./cli.js",
"dependencies": {
},
"bundleDependencies": [
Expand All @@ -32,11 +31,9 @@
"devDependencies": {
},
"engines": {
"node": "0.6 || 0.7 || 0.8",
"npm": "1"
"node": "0.6 || 0.7 || 0.8"
},
"scripts": {
"test": "node ./test/run.js",
"test": "node ./test/run.js"
}
}

}

0 comments on commit 0160528

Please sign in to comment.