flex-combo
Advanced tools
Comparing version 0.11.5 to 0.11.6
30
api.js
@@ -8,8 +8,9 @@ var urlLib = require("url"); | ||
var merge = require("merge"); | ||
var Helper = require("./lib/util"); | ||
var fetch = require("fetch-agent"); | ||
var DAC = require("dac"); | ||
var fetch = require("fetch-agent"); | ||
var isUtf8 = DAC.isUtf8; | ||
var iconv = DAC.iconv; | ||
var Helper = require("./lib/util"); | ||
var ENGINES = []; | ||
@@ -28,6 +29,8 @@ | ||
this.query = {}; | ||
this.cacheDir = pathLib.join(process.cwd(), ".cache"); | ||
this.result = {}; | ||
this.cacheDir = null; | ||
if (confFile) { | ||
this.cacheDir = pathLib.join(pathLib.dirname(confFile), "../.cache"); | ||
var confJSON = {}; | ||
@@ -51,6 +54,17 @@ try { | ||
var root = this.param.rootdir || "src"; | ||
if (root.indexOf('/') == 0 || /^\w{1}:\\.*$/.test(root)) { | ||
this.param.rootdir = pathLib.normalize(root); | ||
} | ||
else { | ||
this.param.rootdir = pathLib.normalize(pathLib.join(process.cwd(), root)); | ||
} | ||
if (!this.param.urls['/']) { | ||
this.param.urls['/'] = this.param.rootdir || "src"; | ||
this.param.urls['/'] = this.param.rootdir; | ||
} | ||
if (!this.cacheDir) { | ||
this.cacheDir = pathLib.join(this.param.rootdir, "../.cache"); | ||
} | ||
if (this.param.cache && !fsLib.existsSync(this.cacheDir)) { | ||
@@ -106,3 +120,3 @@ mkdirp(this.cacheDir, function(e, dir) { | ||
var protocol = (this.req.protocol || "http") + ':'; | ||
var protocol = (this.req.connection.encrypted ? "https" : "http") + ':'; | ||
var H = this.req.headers.host.split(':'); | ||
@@ -142,3 +156,3 @@ var reqPort = H[1] || (protocol == "https:" ? 443 : 80); | ||
this.HOST = (req.protocol || "http") + "://" + (req.hostname || req.host || req.headers.host); | ||
this.HOST = (req.connection.encrypted ? "https" : "http") + "://" + (req.hostname || req.host || req.headers.host); | ||
// 不用.pathname的原因是由于??combo形式的url,parse方法解析有问题 | ||
@@ -183,3 +197,3 @@ this.URL = urlLib.parse(req.url).path.replace(/([^\?])\?[^\?].*$/, "$1"); | ||
var filteredURL = Helper.filteredUrl(_url, this.param.filter, this.param.traceRule); | ||
var absPath = Helper.getRealPath(filteredURL, this.param.filter, this.param.urls); | ||
var absPath = Helper.getRealPath(filteredURL, this.param.urls); | ||
@@ -217,3 +231,3 @@ var matchedIndex = -1; | ||
var filteredURL = Helper.filteredUrl(_url, this.param.filter, false); | ||
var absPath = Helper.getRealPath(filteredURL, this.param.filter, this.param.urls); | ||
var absPath = Helper.getRealPath(filteredURL, this.param.urls); | ||
@@ -220,0 +234,0 @@ if (!this.result[_url]) { |
25
index.js
@@ -11,18 +11,13 @@ /** | ||
try { | ||
var pkg = require(__dirname + "/package.json"); | ||
var pkg = require(__dirname + "/package.json"); | ||
require("check-update")({ | ||
packageName: pkg.name, | ||
packageVersion: pkg.version, | ||
isCLI: process.title == "node" | ||
}, function (err, latestVersion, defaultMessage) { | ||
if (!err && pkg.version < latestVersion) { | ||
console.log(defaultMessage); | ||
} | ||
}); | ||
require("check-update")({ | ||
packageName: pkg.name, | ||
packageVersion: pkg.version, | ||
isCLI: process.title == "node" | ||
}, function (err, latestVersion, defaultMessage) { | ||
if (!err && pkg.version < latestVersion) { | ||
console.log(defaultMessage); | ||
} | ||
}); | ||
} | ||
catch (e) { | ||
} | ||
var fcInst = new API(); | ||
@@ -29,0 +24,0 @@ fcInst.addEngine("\\.less$|\\.less\\.css$", DAC.less, "dac/less"); |
@@ -40,4 +40,4 @@ var fsLib = require("fs"); | ||
/* 获取应用filter规则后的本地地址 */ | ||
exports.getRealPath = function (_url, filter, map) { | ||
/* 获取本地地址 */ | ||
exports.getRealPath = function (_url, map) { | ||
_url = (/^\//.test(_url) ? '' : '/') + _url; | ||
@@ -59,11 +59,3 @@ map = map || {}; | ||
var absPath = ''; | ||
if (repPath.indexOf('/') == 0 || /^\w{1}:\\.*$/.test(repPath)) { | ||
absPath = pathLib.normalize(pathLib.join(repPath, revPath)); | ||
} | ||
else { | ||
absPath = pathLib.normalize(pathLib.join(process.cwd(), repPath, revPath)); | ||
} | ||
return absPath; | ||
return pathLib.normalize(pathLib.join(repPath, revPath)); | ||
}; | ||
@@ -165,2 +157,2 @@ | ||
} | ||
})(); | ||
})(); |
{ | ||
"name": "flex-combo", | ||
"version": "0.11.5", | ||
"version": "0.11.6", | ||
"description": "A combo tool designed for web front-end developer, which support various kinds of combo format by modify configuration(eg. yahoo combo).", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"commander": "~2.5.0", | ||
"dac": "~0.5.1", | ||
"dac": "~0.5.2", | ||
"fetch-agent": "~0.2.3", | ||
@@ -16,0 +16,0 @@ "mace": "~2.0.0", |
Sorry, the diff of this file is not supported yet
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
80245
17
710
Updateddac@~0.5.2