Skip to content

Commit

Permalink
Create client function to setup server. [node_publish] (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanedell authored Dec 13, 2022
1 parent 78cb5c2 commit b741021
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.13)

# Project information
project(omega_edit
VERSION 0.9.29
VERSION 0.9.30
DESCRIPTION "Apache open source library for building editors"
HOMEPAGE_URL "https://github.com/ctc-oss/omega-edit"
LANGUAGES C CXX)
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/client/ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/rpc/client/ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omega-edit",
"version": "0.9.29",
"version": "0.9.30",
"description": "OmegaEdit gRPC Client TypeScript Types",
"publisher": "ctc-oss",
"repository": {
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/client/ts/src/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ declare module 'omega-edit/server' {
omegaEditVersion: string
): Promise<number | undefined>
export function stopServer(id: number | undefined): Promise<boolean>
export function setupServer(
rootPath: string,
omegaEditVersion: string
): Promise<[string, string]>
}
23 changes: 15 additions & 8 deletions src/rpc/client/ts/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import * as unzip from 'unzip-stream'
import * as os from 'os'
import * as child_process from 'child_process'

// const xdgAppPaths = XDGAppPaths({ name: 'omega_edit' })
const wait_port = require('wait-port')

class Artifact {
name: string
archive: string
Expand All @@ -45,6 +42,9 @@ class Artifact {
}
}

// const xdgAppPaths = XDGAppPaths({ name: 'omega_edit' })
const wait_port = require('wait-port')

async function unzipFile(zipFilePath: string, extractPath: string) {
return await new Promise((resolve, reject) => {
let stream = fs
Expand All @@ -60,18 +60,16 @@ async function unzipFile(zipFilePath: string, extractPath: string) {
})
}

export async function startServer(
export async function setupServer(
rootPath: string,
omegaEditVersion: string
): Promise<number | undefined> {
): Promise<[string, string]> {
const artifact = new Artifact(
'omega-edit-scala-server',
omegaEditVersion,
'omega-edit-grpc-server'
)

// let rootPath = xdgAppPaths.data()

if (!fs.existsSync(rootPath)) {
fs.mkdirSync(rootPath, { recursive: true })
}
Expand Down Expand Up @@ -107,7 +105,16 @@ export async function startServer(
)
}

let server = child_process.spawn(artifact.scriptName, [], {
return [artifact.scriptName, scriptPath]
}

export async function startServer(
rootPath: string,
omegaEditVersion: string
): Promise<number | undefined> {
const [scriptName, scriptPath] = await setupServer(rootPath, omegaEditVersion)

let server = child_process.spawn(scriptName, [], {
cwd: `${scriptPath}/bin`,
detached: true,
})
Expand Down

0 comments on commit b741021

Please sign in to comment.