Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit 5f11d81

Browse files
authored
Merge pull request #38 from sckoh/master
Added options to disable using public tunnel. Thanks to @sckoh .
2 parents 6c5fdc2 + 2c86698 commit 5f11d81

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

dist/server.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
express = require('express'),
1212
app = express(),
1313
assetPort = process.env.PORT || 31284,
14+
disablePublicTunnel = process.env.DISABLE_PUBLIC_TUNNEL || false,
1415
compression = require('compression'),
1516
build = require('./build.js').execute,
1617
minimatch = require('minimatch'),
@@ -44,14 +45,17 @@
4445
funcs = [];
4546

4647
funcs.push(function () {
48+
if (disablePublicTunnel) return;
4749
return publicTunnel(assetPort);
4850
});
4951

5052
funcs.push(function (content_url) {
5153
var dfd = Q.defer();
5254

53-
opts.content_url = content_url;
54-
chcpContext.argv.content_url = content_url;
55+
if (!disablePublicTunnel) {
56+
opts.content_url = content_url;
57+
chcpContext.argv.content_url = content_url;
58+
}
5559

5660
dfd.resolve();
5761
return dfd.promise;
@@ -73,9 +77,12 @@
7377
return build(chcpContext);
7478
});
7579

76-
funcs.push(function () {
80+
funcs.push(function (config) {
81+
if (disablePublicTunnel) {
82+
updateLocalEnv({ content_url: config.content_url });
83+
}
7784
console.log('cordova-hcp local server available at: ' + opts.local_url);
78-
console.log('cordova-hcp public server available at: ' + opts.content_url);
85+
console.log('cordova-hcp public server available at: ' + config.content_url);
7986
});
8087

8188
return funcs.reduce(Q.when, Q('initial'));

src/server.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
express = require('express'),
1010
app = express(),
1111
assetPort = process.env.PORT || 31284,
12+
disablePublicTunnel = process.env.DISABLE_PUBLIC_TUNNEL || false,
1213
compression = require('compression'),
1314
build = require('./build.js').execute,
1415
minimatch = require('minimatch'),
@@ -42,14 +43,18 @@
4243
funcs = [];
4344

4445
funcs.push(function(){
46+
if (disablePublicTunnel)
47+
return;
4548
return publicTunnel(assetPort);
4649
});
4750

4851
funcs.push(function(content_url) {
4952
var dfd = Q.defer();
5053

51-
opts.content_url = content_url;
52-
chcpContext.argv.content_url = content_url;
54+
if (!disablePublicTunnel) {
55+
opts.content_url = content_url;
56+
chcpContext.argv.content_url = content_url;
57+
}
5358

5459
dfd.resolve();
5560
return dfd.promise;
@@ -71,9 +76,12 @@
7176
return build(chcpContext);
7277
});
7378

74-
funcs.push(function(){
75-
console.log('cordova-hcp local server available at: '+ opts.local_url);
76-
console.log('cordova-hcp public server available at: ' + opts.content_url);
79+
funcs.push(function(config){
80+
if (disablePublicTunnel) {
81+
updateLocalEnv({ content_url: config.content_url })
82+
}
83+
console.log('cordova-hcp local server available at: ' + opts.local_url);
84+
console.log('cordova-hcp public server available at: ' + config.content_url);
7785
});
7886

7987
return funcs.reduce(Q.when, Q('initial'));

0 commit comments

Comments
 (0)