flex-combo
Advanced tools
Comparing version 0.8.6 to 0.9.0
25
api.js
@@ -98,16 +98,3 @@ var urlLib = require("url"); | ||
}, | ||
engines: [ | ||
{ | ||
rule: "\\.less$|\\.less\\.css$", | ||
func: require("./engines/less") | ||
}, | ||
{ | ||
rule: "\\.scss$|\\.scss\\.css$", | ||
func: require("./engines/sass") | ||
}, | ||
{ | ||
rule: "\\.jpl$|\\.html.js$|\\.tpl.js$", | ||
func: require("./engines/jpl") | ||
} | ||
], | ||
engines: [], | ||
addEngine: function (rule, func) { | ||
@@ -196,3 +183,3 @@ if (rule && typeof func == "function") { | ||
buildRequestOption: function (url) { | ||
if (this.req.headers["x-via"] == "flex-combo") { | ||
if (this.req.headers["x-broker"] == "flex-combo") { | ||
return false; | ||
@@ -216,2 +203,6 @@ } | ||
if (reqHostIP == reqHostName && this.req.url.match(/favicon\.ico$/)) { | ||
return false; | ||
} | ||
var requestOption = { | ||
@@ -224,3 +215,3 @@ protocol: protocol, | ||
headers: { | ||
"x-via": "flex-combo", | ||
"x-broker": "flex-combo", | ||
host: reqHostName | ||
@@ -398,2 +389,2 @@ } | ||
exports = module.exports = FlexCombo; | ||
module.exports = FlexCombo; |
@@ -9,6 +9,4 @@ /** | ||
var fcInst = new FlexCombo(); | ||
// 自定义URL解析规则 | ||
fcInst.defineParser(function (url) { | ||
FlexCombo.prototype.defineParser(function (url) { | ||
return []; | ||
@@ -19,4 +17,4 @@ }); | ||
// 例如要加入stylus支持,首先要在配置文件supportedFile中加入相应后缀匹配\\.styl$,然后通过addEngine添加动态编译逻辑 | ||
fcInst.addEngine("\\.styl$", function (absPath, url) { | ||
return null; | ||
FlexCombo.prototype.addEngine("\\.styl$", function (absPath, url, param, callback) { | ||
callback(err, text, filepath); | ||
}); | ||
@@ -26,3 +24,3 @@ | ||
.createServer(function (req, res) { | ||
fcInst = new FlexCombo(); | ||
var fcInst = new FlexCombo(); | ||
fcInst.handle(req, res, function () { | ||
@@ -29,0 +27,0 @@ res.writeHead(404, {"Content-Type": "text/plain"}); |
40
index.js
@@ -6,4 +6,7 @@ /** | ||
var FlexCombo = require("./api"); | ||
var DAC = require("dac"); | ||
FlexCombo.prototype.addEngine("\\.less$|\\.less\\.css$", DAC.less); | ||
FlexCombo.prototype.addEngine("\\.jpl$", DAC.jpl); | ||
module.exports = function (param, dir) { | ||
exports = module.exports = function (param, dir) { | ||
return function () { | ||
@@ -42,2 +45,37 @@ var fcInst = new FlexCombo(param, dir); | ||
} | ||
}; | ||
exports.engine = function(param, dir) { | ||
param = param || {}; | ||
var through = require("through2"); | ||
var pathLib = require("path"); | ||
var fcInst = new FlexCombo(param, dir); | ||
fcInst.param.traceRule = false; | ||
return through.obj(function (file, enc, cb) { | ||
var self = this; | ||
if (file.isNull()) { | ||
self.emit("error", "isNull"); | ||
cb(null, file); | ||
return; | ||
} | ||
if (file.isStream()) { | ||
self.emit("error", "Streaming not supported"); | ||
cb(null, file); | ||
return; | ||
} | ||
var url = file.path.replace(pathLib.join(process.cwd(), fcInst.param.rootdir), ''); | ||
fcInst.engineHandler(url, function() { | ||
var buff = fcInst.result[url]; | ||
if (buff) { | ||
file.contents = buff; | ||
} | ||
self.push(file); | ||
cb(); | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "flex-combo", | ||
"version": "0.8.6", | ||
"version": "0.9.0", | ||
"description": "A combo tool designed for web front-end developer, which support various kinds of combo format by modify configuration(eg. yahoo combo).", | ||
"main": "index.js", | ||
"scripts": { | ||
"postinstall": "node ./scripts/asksass.js" | ||
}, | ||
"bin": { | ||
@@ -15,8 +12,8 @@ "flex-combo": "./bin/flex-combo" | ||
"commander": "~2.5.0", | ||
"dac": "~0.2.0", | ||
"iconv-lite": "~0.4.4", | ||
"is-utf8": "~0.2.0", | ||
"juicer": "~0.6.6-stable", | ||
"less": "~2.2.0", | ||
"mace": "~2.0.0", | ||
"mime": "~1.2.11" | ||
"mime": "~1.2.11", | ||
"through2": "~0.6.3" | ||
}, | ||
@@ -23,0 +20,0 @@ "repository": { |
@@ -262,7 +262,5 @@ # Flex Combo 介绍 | ||
var fcInst = new FlexCombo(); | ||
// 自定义URL解析规则 | ||
fcInst.defineParser(function(url) { | ||
return []; | ||
FlexCombo.prototype.defineParser(function (url) { | ||
return []; | ||
}); | ||
@@ -272,14 +270,15 @@ | ||
// 例如要加入stylus支持,首先要在配置文件supportedFile中加入相应后缀匹配\\.styl$,然后通过addEngine添加动态编译逻辑 | ||
fcInst.addEngine("\\.styl$", function(absPath, url) { | ||
return null; | ||
FlexCombo.prototype.addEngine("\\.styl$", function (absPath, url, param, callback) { | ||
callback(err, text, filepath); | ||
}); | ||
http.createServer(function(req, res) { | ||
fcInst = new FlexCombo([param], [dir]); | ||
fcInst.handle(req, res, function() { | ||
res.writeHead(404, {"Content-Type": "text/plain"}); | ||
res.end("Your combo file not found."); | ||
http | ||
.createServer(function (req, res) { | ||
var fcInst = new FlexCombo(); | ||
fcInst.handle(req, res, function () { | ||
res.writeHead(404, {"Content-Type": "text/plain"}); | ||
res.end("Your combo file not found."); | ||
}); | ||
}) | ||
.listen(1234); | ||
}) | ||
.listen(1234); | ||
``` | ||
@@ -286,0 +285,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
0
3
4
45408
13
597
292
+ Addeddac@~0.2.0
+ Addedthrough2@~0.6.3
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddac@0.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedthrough2@0.6.5(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedjuicer@~0.6.6-stable
- Removedless@~2.2.0