https://github.com/diversen/detect-process
Nodejs lib that detects if an environment is nodejs, electron, og browser
https://github.com/diversen/detect-process
Last synced: 9 days ago
JSON representation
Nodejs lib that detects if an environment is nodejs, electron, og browser
- Host: GitHub
- URL: https://github.com/diversen/detect-process
- Owner: diversen
- Created: 2017-01-08T17:36:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-10T07:14:03.000Z (over 9 years ago)
- Last Synced: 2025-10-20T02:15:42.857Z (9 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# detect-process
Detect if the running process context is `nodejs`, `phantomjs`, `electron`, or `browser`. Then you can create scripts that e.g. runs both in e.g. electron and the browser. Or at least find a way to determine which elements you will need to include, depending on the context.
Usage in nodejs:
~~~js
var detect = require('detect-process');
var env = detect.getName();
console.log(env); // => nodejs, phantom, electron or browser
~~~
Usage in a browser:
~~~html
var test = detectProcess.getName();
console.log(test); // => nodejs, phantom, electron or browser
~~~
Example in phantomjs:
~~~js
var filename = './dist/detectProcess.js';
injected = phantom.injectJs(filename);
if (injected) {
var process = detectProcess.getName();
console.log(process); // => phantomjs
phantom.exit(0);
}
~~~
License MIT