-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run the dotnet Data Provider from electron (#36)
- console messages are passed through to the electron console - add GHA dotnet build - also `npx update-browserslist-db@latest` - note: in dev, close the app (before ctrl + c) so that the dotnet process is killed
- Loading branch information
1 parent
72b26a8
commit 5a32cf4
Showing
9 changed files
with
178 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { ChildProcessWithoutNullStreams, spawn } from 'child_process'; | ||
import path from 'path'; | ||
|
||
let dotnet: ChildProcessWithoutNullStreams | undefined; | ||
|
||
function killDotnetDataProvider() { | ||
if (!dotnet) return; | ||
|
||
if (dotnet.kill()) { | ||
console.log('[dotnet data provider] was killed'); | ||
} else { | ||
console.error( | ||
'[dotnet data provider] was not stopped! Investigate other .kill() options', | ||
); | ||
} | ||
dotnet = undefined; | ||
} | ||
|
||
/** | ||
* Starts the Dotnet Data Provider if it isn't already running. | ||
*/ | ||
function startDotnetDataProvider() { | ||
if (dotnet) return; | ||
|
||
// default values for development | ||
let command = process.platform.includes('win') ? 'npm.cmd' : 'npm'; | ||
let args: string[] = ['run', 'start:data']; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
if (process.platform === 'win32') { | ||
command = path.join( | ||
process.resourcesPath, | ||
'dotnet', | ||
'ParanextDataProvider.exe', | ||
); | ||
args = []; | ||
} else { | ||
command = path.join( | ||
process.resourcesPath, | ||
'dotnet', | ||
'ParanextDataProvider', | ||
); | ||
args = []; | ||
} | ||
} | ||
|
||
dotnet = spawn(command, args); | ||
|
||
dotnet.stdout.on('data', (data) => { | ||
console.log(`[dotnet data provider] stdout: ${data}`); | ||
}); | ||
|
||
dotnet.stderr.on('data', (data) => { | ||
console.error(`[dotnet data provider] stderr: ${data}`); | ||
}); | ||
|
||
dotnet.on('close', (code, signal) => { | ||
if (signal) { | ||
console.log(`[dotnet data provider] terminated with signal ${signal}`); | ||
} else { | ||
console.log(`[dotnet data provider] exited with code ${code}`); | ||
} | ||
}); | ||
} | ||
|
||
const dotnetDataProvider = { | ||
start: startDotnetDataProvider, | ||
kill: killDotnetDataProvider, | ||
}; | ||
export default dotnetDataProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters