Open tlm-daniele-ricci opened 3 years ago
This would require combining node-windows with node-mac and node-linux. The purpose of separating the libraries is to minimize the code shipped with production apps. For example, there is no point in shipping winsw.exe with macOS or Linux.
Testing a background service on each OS would still require the test to be run on each different operating system, so I'm not sure how much time this would realistically save. Even if it does, it will create bloated output for some operating systems.
I'll leave this open so others can vote on it.
Agreed with this suggestion, my use case is not for tests, but sure it would be useful.
Currently we are using node-windows for a multiplatform electron app, I was writing a factory class which implements node-windows service or node-mac service depending on the os, but i'm stuck due to this, i'm requiring both packages but get the error at the execution. Would be great for our use case of service registering working for the same app in both OS.
Note: As workaround I just removed the ifs at the start of node-windows and node-mac from my node_modules, but I don't want to be doing this every time when installing my dependencies.
// node_modules/node-windows/lib/node-windows.js
if (require('os').platform().indexOf('win32') < 0) {
throw 'node-windows is only supported on Windows.';
}
// node_modules/node-mac/lib/node-mac.js
if (require('os').platform().indexOf('darwin') < 0){
throw 'ngn-mac is only supported on Mac OSX.';
}
Is your feature request related to a problem? Please describe. It's hard to test scripts on Mac or Linux as we can't neither
require
the package.Describe the solution you'd like The only way I found to test my programs on Linux is to write a mock, ok, quite easy. When working on large program, probably it's not a problem, the mock could be useful for many other reasons. But sometimes it happens that we have to work on short scripts. To write a mock to test a 30 lines script could mean double or triple the time to write the script...
Describe alternatives you've considered So I think that letting us to
require
the package, to callnew
and to attach listeners even if not under Windows and throw the exception only when it's performed an operation that actually can be done only under Windows would facilitate the tests of short scripts also under Linux or Mac.Additional context A quick script to try to be a bit more clear.
Once said that, great job! Thank you very much!