Remove peerDependencies, use express directly.

This commit is contained in:
Samuel Reed 2014-07-10 14:08:21 -05:00
parent 75713f16f2
commit cbf768f0b8
2 changed files with 7 additions and 35 deletions

View File

@ -5,11 +5,8 @@
var path = require('path');
var urlJoin = require('./lib/url-join');
var _defaults = require('lodash.defaults');
var extend = require('util')._extend;
var loopback = require('loopback');
var express = requireLoopbackDependency('express');
var express = require('express');
var swagger = require('./lib/swagger');
var fs = require('fs');
var SWAGGER_UI_ROOT = path.join(__dirname, 'node_modules',
'swagger-ui', 'dist');
var STATIC_ROOT = path.join(__dirname, 'public');
@ -58,33 +55,12 @@ function explorer(loopbackApplication, options) {
// In this way one could e.g. make changes to index.html without having
// to worry about constantly pulling in JS updates.
if (options.swaggerDistRoot) {
app.use(loopback.static(options.swaggerDistRoot));
app.use(express.static(options.swaggerDistRoot));
}
// File in node_modules are overridden by a few customizations
app.use(loopback.static(STATIC_ROOT));
app.use(express.static(STATIC_ROOT));
// Swagger UI distribution
app.use(loopback.static(SWAGGER_UI_ROOT));
app.use(express.static(SWAGGER_UI_ROOT));
return app;
}
function requireLoopbackDependency(module) {
try {
return require('loopback/node_modules/' + module);
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') throw err;
try {
// Dependencies may be installed outside the loopback module,
// e.g. as peer dependencies. Try to load the dependency from there.
return require(module);
} catch (errPeer) {
if (errPeer.code !== 'MODULE_NOT_FOUND') throw errPeer;
// Rethrow the initial error to make it clear that we were trying
// to load a module that should have been installed inside
// "loopback/node_modules". This should minimise end-user's confusion.
// However, such situation should never happen as `require('loopback')`
// would have failed before this function was even called.
throw err;
}
}
}

View File

@ -6,10 +6,6 @@
"scripts": {
"test": "mocha"
},
"peerDependencies": {
"loopback": "2.x || 1.x >=1.5",
"strong-remoting": "2.x || 1.x >=1.5"
},
"repository": {
"type": "git",
"url": "git://github.com/strongloop/loopback-explorer.git"
@ -28,8 +24,7 @@
"loopback": "1.x",
"mocha": "~1.14.0",
"supertest": "~0.8.1",
"chai": "~1.8.1",
"express": "3.x"
"chai": "~1.8.1"
},
"license": {
"name": "Dual MIT/StrongLoop",
@ -39,6 +34,7 @@
"swagger-ui": "~2.0.17",
"debug": "~1.0.2",
"lodash.clonedeep": "^2.4.1",
"lodash.defaults": "^2.4.1"
"lodash.defaults": "^2.4.1",
"express": "4.x"
}
}