Replies: 0 comments 8 replies
|
Assuming you don't have access to an ENV that has a platform var (because then you could just check that), you could write a function that was something along the lines of to check for termux! |
|
You can determine if the current instance of Node.js is running on Termux by checking the PREFIX environment variable, which is unique to Termux. Here's a concise implementation: const isTermux = () => { if (isTermux()) { Explanation:
|
|
Currently im using a config file per installation of app which runs on Node, its ignored in synchronization and Source Control, and contains specification of the type of system. |
You can determine if the current instance of Node.js is running on Termux by checking the PREFIX environment variable, which is unique to Termux. Here's a concise implementation:
const isTermux = () => {
const termuxEnv = process.env.PREFIX;
return termuxEnv && termuxEnv.includes('com.termux');
};
if (isTermux()) {
console.log('Running on Termux');
} else {
console.log('Not running on Termux');
}
Explanation:
Why PREFIX?
In Termux, the PREFIX environment variable is set to /data/data/com.termux/files/usr, which identifies Termux's unique environment.
How It Works:
The function checks for the existence of process.env.PREFIX and verifies if it contains the string com.termux, making it a…