Skip to content
Browse files

为第一次发布到npm做改动

配置目录只使用~/.dproxy弃用程序目录下的conf
setting中添加判断.dproxy是否存在,自动拷贝conf目录内容创建.dproxy
判断dproxy.conf文件是否存在,提示用户创建配置
修改package.json支持npm install -g
  • Loading branch information...
1 parent f3ef0da commit 01605287da9cd82edc576e54b7d347b8dcceb583 deemstone committed Feb 20, 2013
Showing with 25 additions and 19 deletions.
  1. +2 −2 cli.js
  2. +1 −1 fun/dproxy-cli.js
  3. +17 −8 fun/settings.js
  4. +5 −8 package.json
View
4 cli.js
@@ -1,6 +1,6 @@
+#!/usr/bin/env node
/*
* dproxy的一个命令行启动器
* 可以手动运行这个程序(./fun/dproxy-cli.js的一个替身)
*/
-
-require('./fun/dproxy-cli.js');
+require('./fun/dproxy-cli.js');
View
2 fun/dproxy-cli.js
@@ -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 );
}
View
25 fun/settings.js
@@ -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;
}
//读取指定配置文件的内容,解析成键值对象
View
13 package.json
@@ -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": {
@@ -22,8 +22,7 @@
"lib": "./lib",
"bin": "./bin"
},
- "main": "./fun/dproxy-cli.js",
- "bin": "./fun/dproxy-cli.js",
+ "bin": "./cli.js",
"dependencies": {
},
"bundleDependencies": [
@@ -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.
Something went wrong with that request. Please try again.