Question

I'm developping a node application, sometimes with Eclipse (locally) and sometimes with Cloud9 (remotely). As I'm using a database, I have one local with mongoDB and another remote on mongoHQ.

If I dont want to use the DB on mongoHQ when I work locally, how could I tell my nodejs application (understand automatically detect) that my IDE is Cloud9 or another one ? I could use a simple local variable that I change each time I change IDE, but is it possible to do it automatically ?

Was it helpful?

Solution

One way to detect is to check if C9_PROJECT environment variable is set:

if (process.env.C9_PROJECT) {
  console.log('Running on C9 IDE');
} else {
  // ...
}

There are also other variables prefixed with C9. You can check them if you want to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top