flex-combo
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -33,3 +33,4 @@ var http = require('http') | ||
}, | ||
supportedFile: '\\.js|\\.css|\\.png|\\.gif|\\.jpg|\\.swf|\\.xml' | ||
supportedFile: '\\.js|\\.css|\\.png|\\.gif|\\.jpg|\\.swf|\\.xml', | ||
prjDir: '' | ||
}; | ||
@@ -74,3 +75,3 @@ | ||
var revPath = fullPath.slice(longestMatchPos.length, fullPath.length); | ||
var absPath = path.normalize(path.join(__dirname, dir, revPath)); | ||
var absPath = path.normalize(path.join(param.prjDir, dir, revPath)); | ||
if(fs.existsSync(absPath)){ | ||
@@ -92,3 +93,3 @@ var buff = fs.readFileSync(absPath); | ||
exports = module.exports = function(urls, options){ | ||
exports = module.exports = function(prjDir, urls, options){ | ||
if(urls){ | ||
@@ -101,2 +102,3 @@ param.urls = merge(param.urls, urls); | ||
} | ||
param.prjDir = prjDir; | ||
var fileReg = new RegExp(param.supportedFile); | ||
@@ -127,3 +129,3 @@ return function(req, res, next) { | ||
//本地没有,从服务器获取 | ||
console.log('send http request:'+ param.host+ url); | ||
//console.log('send http request:'+ param.host+ url); | ||
http.get({host: param.host, port: 80, path: url}, function(resp) { | ||
@@ -143,3 +145,3 @@ var buffs = []; | ||
}).on('error',function(e){ | ||
console.log('Networking error:' + e.message); | ||
//console.log('Networking error:' + e.message); | ||
return; | ||
@@ -150,5 +152,5 @@ }); | ||
prefix = url.substring(0, prefix); | ||
console.log(prefix+'|'+param.servlet); | ||
//console.log(prefix+'|'+param.servlet); | ||
var files = url.substring(prefix.length + param.servlet.length + 1, url.length); | ||
console.log(files); | ||
//console.log(files); | ||
files = files.split(param.seperator, 1000); | ||
@@ -188,6 +190,6 @@ | ||
(function(id) { | ||
console.log('define request: '+ reqArray[i].file); | ||
//console.log('define request: '+ reqArray[i].file); | ||
http.get({host: param.host, port: 80, path: url}, function(resp) { | ||
var buffs = []; | ||
console.log('request: ' + reqPath+reqArray[id].file); | ||
//console.log('request: ' + reqPath+reqArray[id].file); | ||
resp.on('data', function(chunk) { | ||
@@ -203,3 +205,3 @@ buffs.push(chunk); | ||
}).on('error',function(e){ | ||
console.log('Networking error:' + e.message); | ||
//console.log('Networking error:' + e.message); | ||
}); | ||
@@ -206,0 +208,0 @@ })(i); |
{ | ||
"name": "flex-combo", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "The Flex-combo is combo tool designed for web front-end developer. It support various kinds of combo format by modify configuration(eg. yahoo combo).", | ||
@@ -5,0 +5,0 @@ "main": "flex-combo.js", |
@@ -17,3 +17,3 @@ #Flex-combo | ||
Open you browser visit | ||
```http://127.0.0.1:1337/test/js/??js1.js,js2.js,js3.js``` | ||
`http://127.0.0.1:1337/test/js/??js1.js,js2.js,js3.js` | ||
@@ -23,7 +23,7 @@ #Useage | ||
``` var flexCombo = require('./flex-combo.js'); ``` | ||
var flexCombo = require('./flex-combo.js'); | ||
Create module instance and pass a configuration like this: | ||
``` var comboInst = flexCombo({'/test': 'test'}); ``` | ||
var comboInst = flexCombo({'/test': 'test'}); | ||
@@ -30,0 +30,0 @@ It meas if a http request start with `http://xxxx.com/test` flex-combo will find file in `./lib' directory. |
var http = require('http'); | ||
var flexCombo = require('./flex-combo.js'); | ||
var comboInst = flexCombo({'/test': 'test'}); | ||
var comboInst = flexCombo(__dirname, {'/test': 'test'}); | ||
http.createServer(function (req, res) { | ||
@@ -5,0 +5,0 @@ comboInst(req, res, function(){ |
9167
214