Shanedell commented on issue #301:
URL:
https://github.com/apache/daffodil-vscode/issues/301#issuecomment-1338038508
Oh okay that makes sense, so two options
Option 1:
Try to make a general function that does an os check then returns the
approiate option
```typescript
function checkOS(windowOption: string, macLinuxOption) {
return os.platform() == 'win32' ? windowsOption : macLinuxOption
}
```
Option 2:
Split code into separate functions, similar to `killPrcoess`
```typescript
function stopDebugger() {
// Stop debugger if running
if (os.platform() === 'win32') {
// Windows stop debugger if already running
child_process.execSync(
'tskill java 2>nul 1>nul || echo "Java not running"'
)
} else {
// Linux/Mac stop debugger if already running and make sure script is
executable
child_process.exec(
"kill -9 $(ps -ef | grep 'daffodil' | grep 'jar' | awk '{ print $2 }')
|| return 0"
) // ensure debugger server not running and
}
}
```
So with option one we could do
```typescript
child_process.exec(
checkOS(
'tskill java 2>nul 1>nul || echo "Java not running"',
"kill -9 $(ps -ef | grep 'daffodil' | grep 'jar' | awk '{ print $2 }')
|| return 0"
)
)
```
instead splitting into a method in option 2. Which would be preferred or a
combination of both?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]