mirror of
https://github.com/gundb/panic-server.git
synced 2026-04-15 03:00:16 -04:00
Add scope controls, loosely type check platform queries.
All tests passing. Added a new keyword (cross-platform) to the package.json file. Optionally, scope variables can be sent to the clients in the `.run` method. Platform queries are now loosely type checked. This allows you to match a number against a string (or vice versa), such as a version or architecture.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "panic-server",
|
||||
"version": "0.0.2",
|
||||
"description": "E2E distributed test framework",
|
||||
"description": "Distributed Javascript runner",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
@@ -14,8 +14,10 @@
|
||||
"gun",
|
||||
"gundb",
|
||||
"test",
|
||||
"eval",
|
||||
"testing",
|
||||
"distributed"
|
||||
"distributed",
|
||||
"cross-platform"
|
||||
],
|
||||
"author": "Jesse Gibson <jesse@gundb.io> (http://techllama.com)",
|
||||
"license": "(Zlib OR MIT OR Apache-2.0)",
|
||||
|
||||
@@ -83,7 +83,7 @@ API.len = function () {
|
||||
return num;
|
||||
};
|
||||
|
||||
API.run = function (cb) {
|
||||
API.run = function (cb, scope) {
|
||||
var key, done = 0, list = this, length = this.len();
|
||||
key = Math.random()
|
||||
.toString(36)
|
||||
@@ -107,7 +107,7 @@ API.run = function (cb) {
|
||||
client.socket.removeListener('disconnect', add);
|
||||
})
|
||||
.once('disconnect', add)
|
||||
.emit('run', cb, key);
|
||||
.emit('run', cb, key, scope);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/*eslint eqeqeq: "off"*/
|
||||
'use strict';
|
||||
function match(query, platform) {
|
||||
var key, value, matches = true;
|
||||
@@ -9,7 +10,8 @@ function match(query, platform) {
|
||||
if (value instanceof RegExp) {
|
||||
matches = matches && !!platform[key].match(value);
|
||||
} else if (typeof value === 'string') {
|
||||
matches = matches && platform[key] === value;
|
||||
// loose type check the value
|
||||
matches = matches && platform[key] == value;
|
||||
} else if (value instanceof Object) {
|
||||
return match(value, platform[key] || {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user