copilot-core
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -15,2 +15,3 @@ "use strict"; | ||
const action_1 = require("./action"); | ||
const cache_1 = require("./util/cache"); | ||
const { debug, warn, error } = require("b-logger")("copilot.main"); | ||
@@ -20,2 +21,3 @@ const { asyncify } = require("array-asyncify"); | ||
let processorNames; | ||
let cache = new cache_1.Cache(); | ||
function startUp() { | ||
@@ -49,2 +51,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
cache.clear(); | ||
} | ||
@@ -92,8 +95,19 @@ exports.run = run; | ||
let cmds = cmd_1.parse(input); | ||
let useCache = true; | ||
return asyncify(cmds) | ||
.reduce((pre, next, idx) => __awaiter(this, void 0, void 0, function* () { | ||
debug("Process: ", next); | ||
let cachedRet = cache.get(next.original); | ||
if (cachedRet && useCache) { | ||
debug("Using cache for ", next.original); | ||
return cachedRet; | ||
} | ||
else { | ||
debug("Dont use cache for ", next.original); | ||
useCache = false; | ||
} | ||
let p = lookup(next.cmd); | ||
if (p) { | ||
ret = yield p(next.args || {}, ret); | ||
ret = yield p(next.args || {}, pre); | ||
cache.set(next.original, ret); | ||
return ret; | ||
@@ -112,5 +126,5 @@ } | ||
} | ||
}), {}); | ||
}), []); | ||
}); | ||
} | ||
exports.handle = handle; |
@@ -38,8 +38,7 @@ "use strict"; | ||
debug("search ", op.strings.join(" ")); | ||
let result = fuse.search(op.strings.join(" ")); | ||
if (op.strings.length === 0) { | ||
return list; | ||
} | ||
let result = fuse.search(op.strings.join(" ")); | ||
return result.map(ret => { | ||
debug(ret); | ||
for (let match of ret.matches) { | ||
@@ -46,0 +45,0 @@ let key = match.key; |
@@ -35,2 +35,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log("@wins.list"); | ||
let ret = yield util_1.default.exec("wmctrl", "-lp"); | ||
@@ -37,0 +38,0 @@ return ret.split("\n") |
{ | ||
"name": "copilot-core", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "copilot", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
46677
45
1342