Skip to content

Commit

Permalink
feat: added dev mode on extension
Browse files Browse the repository at this point in the history
  • Loading branch information
gp-pereira committed Nov 24, 2024
1 parent d834560 commit e0d0c80
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
15 changes: 14 additions & 1 deletion extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "refatorex",
"publisher": "gp-pereira",
"displayName": "Refactorex",
"version": "0.0.8",
"version": "0.2.0",
"author": {
"name": "gp-pereira",
"url": "https://www.github.com/gp-pereira"
Expand Down Expand Up @@ -30,6 +30,19 @@
"code actions",
"keybindings"
],
"contributes": {
"configuration": {
"type": "object",
"title": "Refactorex",
"properties": {
"refactorex.devPort": {
"type": "string",
"description": "Port number for a local RefactorEx server",
"default": ""
}
}
}
},
"icon": "icon.png",
"main": "./out/extension.js",
"scripts": {
Expand Down
20 changes: 14 additions & 6 deletions extensions/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ export async function activate(context: ExtensionContext) {
"refactorex",
"Refactorex",
async () => {
await ensureServerCompiled(serverPath);
let port = workspace
.getConfiguration("refactorex")
.get<number>("devPort");

const port = await findAvailablePort();
server = startServer(serverPath, port);
if (!port) {
await ensureServerCompiled(serverPath);

// giving the server some time to start
await new Promise((r) => setTimeout(r, 1000));
port = await findAvailablePort();
server = startServer(serverPath, port);

client.info(`Server started on port ${port}`);
// giving the server some time to start
await new Promise((r) => setTimeout(r, 1000));

client.info(`Server started on port ${port}`);
} else {
client.info(`Server expected on port ${port}`);
}

const socket = await connect(port);
return { writer: socket, reader: socket };
Expand Down

0 comments on commit e0d0c80

Please sign in to comment.