mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-03 21:23:05 +00:00
feature(cloudcmd) add ability to override modules (#109)
This commit is contained in:
parent
3044ac0c88
commit
51481fb054
13 changed files with 201 additions and 128 deletions
|
|
@ -19,7 +19,7 @@ module.exports = (options, fn = options) => {
|
|||
options = {};
|
||||
}
|
||||
|
||||
const {config, plugins} = options;
|
||||
const {config, plugins, modules} = options;
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
|
|
@ -35,7 +35,8 @@ module.exports = (options, fn = options) => {
|
|||
app.use(cloudcmd({
|
||||
socket,
|
||||
plugins,
|
||||
config: assign(defaultConfig(), config)
|
||||
config: assign(defaultConfig(), config),
|
||||
modules,
|
||||
}));
|
||||
|
||||
server.listen(() => {
|
||||
|
|
|
|||
67
test/server/modulas.js
Normal file
67
test/server/modulas.js
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const test = require('tape');
|
||||
|
||||
const promisify = require('es6-promisify');
|
||||
const pullout = require('pullout');
|
||||
const request = require('request');
|
||||
|
||||
const modulesPath = path.join(__dirname, '..', '..', 'json', 'modules.json');
|
||||
const localModules = require(modulesPath);
|
||||
|
||||
const warp = (fn, ...a) => (...b) => fn(...b, ...a);
|
||||
const _pullout = promisify(pullout);
|
||||
|
||||
const get = promisify((url, fn) => {
|
||||
fn(null, request(url));
|
||||
});
|
||||
|
||||
const before = require('../before');
|
||||
|
||||
test('cloudcmd: modules', (t) => {
|
||||
const modules = {
|
||||
data: {
|
||||
FilePicker: {
|
||||
key: 'hello'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const expected = Object.assign({}, localModules);
|
||||
|
||||
expected.data.FilePicker.key = 'hello';
|
||||
|
||||
before({modules}, (port, after) => {
|
||||
get(`http://localhost:${port}/json/modules.json`)
|
||||
.then(warp(_pullout, 'string'))
|
||||
.then(JSON.parse)
|
||||
.then((result) => {
|
||||
t.deepEqual(result, expected, 'should equal');
|
||||
t.end();
|
||||
after();
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: modules: wrong route', (t) => {
|
||||
const modules = {
|
||||
hello: 'world'
|
||||
};
|
||||
|
||||
const expected = Object.assign({}, localModules, modules);
|
||||
|
||||
before({modules}, (port, after) => {
|
||||
get(`http://localhost:${port}/package.json`)
|
||||
.then(warp(_pullout, 'string'))
|
||||
.then(JSON.parse)
|
||||
.then((result) => {
|
||||
t.notDeepEqual(result, expected, 'should not be equal');
|
||||
t.end();
|
||||
after();
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue