mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
feature(binom) add
This commit is contained in:
parent
6b8235c002
commit
68114e5ac5
2 changed files with 30 additions and 3 deletions
27
lib/server/binom.js
Normal file
27
lib/server/binom.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
module.exports = binom;
|
||||
|
||||
function binom(name, array) {
|
||||
var ret;
|
||||
|
||||
if (typeof name !== 'string')
|
||||
throw(Error('name should be string!'));
|
||||
|
||||
if (!Array.isArray(array))
|
||||
throw(Error('array should be array!'));
|
||||
|
||||
array.some(function(item) {
|
||||
var is = item.name === name;
|
||||
|
||||
if (is)
|
||||
ret = item;
|
||||
|
||||
return is;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
path = require('path'),
|
||||
root = require(DIR + 'root'),
|
||||
binom = require(DIR + 'binom'),
|
||||
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
|
||||
markdown = require(DIR + 'rest/markdown'),
|
||||
|
|
@ -149,8 +149,8 @@
|
|||
}
|
||||
|
||||
function auth(code, callback) {
|
||||
var storage = Util.findObjByNameInArr(Modules, 'storage'),
|
||||
gh = Util.findObjByNameInArr(storage, 'GitHub'),
|
||||
var storage = binom(Modules, 'storage'),
|
||||
gh = binom(storage, 'GitHub'),
|
||||
env = process.env,
|
||||
|
||||
key = env.github_key || gh.key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue