flex-combo
Advanced tools
Comparing version 0.11.6 to 0.12.0
37
api.js
@@ -26,3 +26,2 @@ var urlLib = require("url"); | ||
}); | ||
this.param = merge(true, require("./lib/param")); | ||
this.query = {}; | ||
@@ -32,8 +31,18 @@ this.result = {}; | ||
this.param = require("./lib/param"); | ||
delete require.cache["./lib/param"]; | ||
param = param || {}; | ||
var confJSON = {}; | ||
if (confFile) { | ||
this.cacheDir = pathLib.join(pathLib.dirname(confFile), "../.cache"); | ||
var confJSON = {}; | ||
if (!fsLib.existsSync(confFile)) { | ||
fsLib.writeFileSync(confFile, JSON.stringify(this.param, null, 2), {encoding: "utf-8"}); | ||
fsLib.chmod(confFile, 0777); | ||
} | ||
try { | ||
confJSON = JSON.parse(fsLib.readFileSync(confFile)); | ||
confJSON = require(confFile); | ||
delete require.cache[confFile]; | ||
} | ||
@@ -44,26 +53,16 @@ catch (e) { | ||
} | ||
this.param = merge.recursive(true, this.param, confJSON, param || {}); | ||
if (confJSON.filter || param.filter) { | ||
this.param.filter = merge(confJSON.filter || {}, param.filter || {}); | ||
} | ||
} | ||
else { | ||
this.param = merge.recursive(true, this.param, param || {}); | ||
} | ||
var root = this.param.rootdir || "src"; | ||
if (root.indexOf('/') == 0 || /^\w{1}:\\.*$/.test(root)) { | ||
this.param.rootdir = pathLib.normalize(root); | ||
this.param = merge.recursive(true, this.param, confJSON, param); | ||
if (confJSON.filter || param.filter) { | ||
this.param.filter = merge(confJSON.filter || {}, param.filter || {}); | ||
} | ||
else { | ||
this.param.rootdir = pathLib.normalize(pathLib.join(process.cwd(), root)); | ||
} | ||
this.param.rootdir = pathLib.normalize(pathLib.join(process.cwd(), this.param.rootdir || "src")); | ||
if (!this.param.urls['/']) { | ||
this.param.urls['/'] = this.param.rootdir; | ||
} | ||
if (!this.cacheDir) { | ||
this.cacheDir = pathLib.join(this.param.rootdir, "../.cache"); | ||
this.cacheDir = pathLib.normalize(pathLib.join(this.param.rootdir, "../.cache")); | ||
} | ||
@@ -70,0 +69,0 @@ if (this.param.cache && !fsLib.existsSync(this.cacheDir)) { |
71
index.js
@@ -7,5 +7,4 @@ /** | ||
var DAC = require("dac"); | ||
var fsLib = require("fs"); | ||
var pathLib = require("path"); | ||
var fsLib = require("fs"); | ||
var mkdirp = require("mkdirp"); | ||
@@ -29,5 +28,4 @@ var pkg = require(__dirname + "/package.json"); | ||
if (typeof result != "undefined") { | ||
var fs = require("fs"); | ||
fs.writeFile(htmlfile, result, function () { | ||
fs.chmod(htmlfile, 0777); | ||
fsLib.writeFile(htmlfile, result, function () { | ||
fsLib.chmod(htmlfile, 0777); | ||
}); | ||
@@ -40,12 +38,21 @@ } | ||
function transfer(dir, key, except) { | ||
var mkdirp = require("mkdirp"); | ||
if (dir) { | ||
var confFile; | ||
if (dir && (/^\//.test(dir) || /^\w{1}:[\\|\/].*$/.test(dir))) { | ||
confFile = pathLib.join(dir, "config.json"); | ||
var confDir, confFile, json = pathLib.basename(__dirname) + ".json"; | ||
if (dir.indexOf('/') == 0 || /^\w{1}:[\\/].*$/.test(dir)) { | ||
if (/\.json$/.test(dir)) { | ||
confFile = dir; | ||
confDir = pathLib.dirname(confFile); | ||
} | ||
else { | ||
confDir = dir; | ||
confFile = pathLib.join(confDir, json); | ||
} | ||
} | ||
else { | ||
confFile = pathLib.join(process.cwd(), dir || ".config", pathLib.basename(__dirname) + ".json"); | ||
confDir = pathLib.join(process.cwd(), dir); | ||
confFile = pathLib.join(confDir, json); | ||
} | ||
var confDir = pathLib.dirname(confFile); | ||
if (!fsLib.existsSync(confDir)) { | ||
@@ -56,27 +63,24 @@ mkdirp.sync(confDir); | ||
if (!fsLib.existsSync(confFile)) { | ||
fsLib.writeFileSync(confFile, JSON.stringify(this.param, null, 2), {encoding: "utf-8"}); | ||
fsLib.chmod(confFile, 0777); | ||
} | ||
if (fsLib.existsSync(confFile)) { | ||
var userParam = require(confFile); | ||
if (key && typeof userParam[key] == "undefined") { | ||
var param = require("./lib/param"); | ||
var keys = Object.keys(param[key]); | ||
var userParam = require(confFile); | ||
if (key && typeof userParam[key] == "undefined") { | ||
var param = require("./lib/param"); | ||
var keys = Object.keys(param[key]); | ||
userParam[key] = {}; | ||
except = except || []; | ||
userParam[key] = {}; | ||
except = except || []; | ||
keys.map(function (i) { | ||
if (except.indexOf(i) == -1 && typeof userParam[i] != "undefined") { | ||
userParam[key][i] = userParam[i]; | ||
delete userParam[i]; | ||
} | ||
else { | ||
userParam[key][i] = param[key][i]; | ||
} | ||
}); | ||
keys.map(function (i) { | ||
if (except.indexOf(i) == -1 && typeof userParam[i] != "undefined") { | ||
userParam[key][i] = userParam[i]; | ||
delete userParam[i]; | ||
} | ||
else { | ||
userParam[key][i] = param[key][i]; | ||
} | ||
}); | ||
fsLib.writeFileSync(confFile, JSON.stringify(userParam, null, 2), {encoding: "utf-8"}); | ||
fsLib.chmod(confFile, 0777); | ||
fsLib.writeFileSync(confFile, JSON.stringify(userParam, null, 2), {encoding: "utf-8"}); | ||
fsLib.chmod(confFile, 0777); | ||
} | ||
} | ||
@@ -131,6 +135,3 @@ | ||
exports.engine = function (param, dir) { | ||
param = param || {}; | ||
var through = require("through2"); | ||
var pathLib = require("path"); | ||
@@ -137,0 +138,0 @@ fcInst = new API(param, transfer(dir, "dac/tpl", ["filter"])); |
{ | ||
"name": "flex-combo", | ||
"version": "0.11.6", | ||
"version": "0.12.0", | ||
"description": "A combo tool designed for web front-end developer, which support various kinds of combo format by modify configuration(eg. yahoo combo).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
80302