mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(cloudcmd) prefix with leading slash (#195)
This commit is contained in:
parent
15abceefeb
commit
b5f9261504
4 changed files with 7 additions and 10 deletions
|
|
@ -11,6 +11,7 @@ const wraptile = require('wraptile');
|
|||
const exit = require(DIR_SERVER + 'exit');
|
||||
const config = require(DIR_SERVER + 'config');
|
||||
const env = require(DIR_SERVER + 'env');
|
||||
const prefixer = require(DIR_SERVER + '/prefixer');
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
|
|
@ -150,7 +151,7 @@ function main() {
|
|||
config('terminalCommand', args['terminal-command']);
|
||||
config('terminalAutoRestart', args['terminal-auto-restart']);
|
||||
config('editor', args.editor);
|
||||
config('prefix', args.prefix);
|
||||
config('prefix', prefixer(args.prefix));
|
||||
config('root', args.root);
|
||||
config('vim', args.vim);
|
||||
config('columns', args.columns);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module.exports.unregisterSW = unregisterSW;
|
|||
const noop = () => {};
|
||||
|
||||
async function registerSW(prefix) {
|
||||
prefix = prefix ? `/${prefix}/` : `/`;
|
||||
prefix = prefix ? `${prefix}/` : `/`;
|
||||
|
||||
if (!navigator.serviceWorker)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ test('sw: register: registerSW', async (t) => {
|
|||
global.location = location;
|
||||
global.navigator = navigator;
|
||||
|
||||
t.ok(register.calledWith('/hello/sw.js'), 'should call register');
|
||||
t.ok(register.calledWith('hello/sw.js'), 'should call register');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -5,21 +5,17 @@ const cloudcmd = require(DIR_SERVER + 'cloudcmd');
|
|||
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
const config = require(DIR_SERVER + 'config');
|
||||
const prefixer = require(DIR_SERVER + 'prefixer');
|
||||
|
||||
const http = require('http');
|
||||
const opn = require('opn');
|
||||
const express = require('express');
|
||||
const io = require('socket.io');
|
||||
const squad = require('squad');
|
||||
const apart = require('apart');
|
||||
|
||||
const tryRequire = require('tryrequire');
|
||||
const logger = tryRequire('morgan');
|
||||
|
||||
const prefix = squad(prefixer, apart(config, 'prefix'));
|
||||
|
||||
module.exports = (options) => {
|
||||
const prefix = config('prefix');
|
||||
const port = process.env.PORT || /* c9 */
|
||||
config('port');
|
||||
|
||||
|
|
@ -36,7 +32,7 @@ module.exports = (options) => {
|
|||
app.use(cloudcmd({
|
||||
config: options,
|
||||
socket: io(server, {
|
||||
path: prefix() + '/socket.io'
|
||||
path: `${prefix}/socket.io`,
|
||||
}),
|
||||
}));
|
||||
|
||||
|
|
@ -46,7 +42,7 @@ module.exports = (options) => {
|
|||
server.listen(port, ip, () => {
|
||||
const host = config('ip') || 'localhost';
|
||||
const port0 = port || server.address().port;
|
||||
const url = `http://${host}:${port0}${prefix()}/`;
|
||||
const url = `http://${host}:${port0}${prefix}/`;
|
||||
|
||||
console.log('url:', url);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue