Skip to content

Commit b2a1053

Browse files
committed
Merge pull request #4 from OpenframeProject/install-plugin
Install plugin
2 parents b43fedd + e09537d commit b2a1053

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/controller.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,12 @@ fc.connect = function(userId) {
218218
resolve();
219219
}
220220

221+
// XXX - POTENTIAL BUG - catch plugin init error separately, otherwise a new frame is created.
221222
frame
222223
.fetch()
223224
.then(function() {
224225
debug('ready to init...');
226+
// initPlugins now always resolves, is never rejected
225227
return pm.initPlugins(frame.state.plugins, fc.pluginApi);
226228
})
227229
.then(readyToConnect)
@@ -380,7 +382,13 @@ fc.pluginApi = {
380382
return fc.pubsub;
381383
},
382384
// access to the Swagger rest client
383-
rest: rest.client
385+
getRest: function() {
386+
return rest.client;
387+
},
388+
// access to the frame model reference
389+
getFrame: function() {
390+
return frame;
391+
}
384392
};
385393

386394
/**

src/plugin-manager.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,18 @@ pm.initPlugins = function(plugins, ofPluginApi) {
8282
var promises = [],
8383
key;
8484

85-
// add each plugin to package.json
86-
for (key in plugins) {
87-
if (plugins.hasOwnProperty(key)) {
88-
promises.push(_initPlugin(key, ofPluginApi));
85+
return new Promise((resolve, reject) => {
86+
// add each plugin to package.json
87+
for (key in plugins) {
88+
if (plugins.hasOwnProperty(key)) {
89+
promises.push(_initPlugin(key, ofPluginApi));
90+
}
8991
}
90-
}
9192

92-
return Promise.all(promises);
93+
Promise.all(promises)
94+
.then(resolve)
95+
.catch(resolve);
96+
});
9397
};
9498

9599
/**
@@ -108,7 +112,7 @@ pm.initPlugins = function(plugins, ofPluginApi) {
108112
*/
109113
function _installPlugin(package_name, version, force) {
110114
debug('installPlugin', package_name, version);
111-
var cmd = 'npm install -g ' + package_name;
115+
var cmd = 'npm install ' + package_name;
112116
if (version) {
113117
cmd += '@'+version;
114118
}

0 commit comments

Comments
 (0)