You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 call new 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.
// ATM neither this is possible under Linux or Mac, while it should be allowedconstnodeWindows=require("node-windows");// This should be allowd under Linux and Macconst{ Service }=nodeWindows;// Also this should be allowd under Linux and Macconstservice=newService({});// Both attaching a listener and referencing an impossible to call method should be allowd under Linux and Mac as wellservice.on("install",()=>service.start());// This can't actually do nothing else than failing if under Linux or Macservice.install();
Once said that, great job! Thank you very much!
Please use the reactions to cast a vote in favor of or against this feature suggestion »
The text was updated successfully, but these errors were encountered:
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.
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!
The text was updated successfully, but these errors were encountered: