I'm writing a couple of node shell scripts for use when developing on a platform. We have both Mac and Windows developers. Is there a variable I can check for in Node to run a .sh file in one instance and .bat in another?
OS is a node module used to provide information about the computer operating system. Advantages: It provides functions to interact with the operating system. It provides the hostname of the operating system and returns the amount of free system memory in bytes.
js v18 is the Current version! Node. js 18 will be the 'Current' release for the next 6 months and then promoted to Long-term Support (LTS) in October 2022.
The variable to use would be process.platform
On Mac the variable is set to darwin
. On Windows, it is set to win32
(even on 64 bit).
Current possible values are:
aix
darwin
freebsd
linux
openbsd
sunos
win32
android
(Experimental, according to the link)I just set this at the top of my jakeFile:
var isWin = process.platform === "win32";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With