Skip to content

Commit

Permalink
Fix mode config not being plumbed + remove extraneous bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuafcole committed Dec 12, 2016
1 parent 65b4311 commit cddbd1f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bin/eve.js
Expand Up @@ -97,9 +97,9 @@ if(!filepath) {
} }


let mode = Mode.workspace; let mode = Mode.workspace;
if(filepath) mode = Mode.file if(filepath && !editor) mode = Mode.file


var opts = {internal: internal, runtimeOwner: runtimeOwner, controlOwner: controlOwner, editor: editor, port: port, path: filepath, internal: internal, root: root, eveRoot: eveRoot}; var opts = {internal: internal, runtimeOwner: runtimeOwner, controlOwner: controlOwner, editor: editor, port: port, path: filepath, internal: internal, root: root, eveRoot: eveRoot, mode};
config.init(opts); config.init(opts);


server.run(opts); server.run(opts);
10 changes: 1 addition & 9 deletions src/runtime/server.ts
Expand Up @@ -186,22 +186,14 @@ function IDEMessageHandler(client:SocketRuntimeClient, message) {
let content:string; let content:string;
let path:string; let path:string;


// If the client is locally controlled it's in charge of its own file management.
// If it's requesting a gist, it needs to fetch elsewhere too.
// This is pretty hacky, but we'll clean it up in post.
if(config.controlOwner === Owner.client ||
hash && hash.indexOf("gist:") === 0) {
return ws.send(JSON.stringify({type: "initProgram", runtimeOwner, controlOwner, path, internal, withIDE: editor}));
}

// If we're in file mode, the only valid file to serve is the one specified in `config.path`. // If we're in file mode, the only valid file to serve is the one specified in `config.path`.
if(mode === Mode.file) { if(mode === Mode.file) {
content = eveSource.find(config.path); content = eveSource.find(config.path);
path = config.path; path = config.path;
} }


// Otherwise, anything goes. First we check if the client has requested a specific file in the URL hash. // Otherwise, anything goes. First we check if the client has requested a specific file in the URL hash.
if(!content && hash) { if(mode === Mode.workspace && hash) {
// @FIXME: This code to strip the editor hash segment out really needs to be abstacted. // @FIXME: This code to strip the editor hash segment out really needs to be abstacted.
let filepath = hash.split("#")[0]; let filepath = hash.split("#")[0];
if(filepath[filepath.length - 1] === "/") filepath = filepath.slice(0, -1); if(filepath[filepath.length - 1] === "/") filepath = filepath.slice(0, -1);
Expand Down

0 comments on commit cddbd1f

Please sign in to comment.