title: read .env file and convert all lines into an object
body: <p>I'm trying to read an <code>.env</code> file that <a href="https://github.com/ddollar/foreman" rel="nofollow">Foreman</a> is using to read env variables that you might want to have when starting the node server.</p>
  
  <p>I'm using:</p>
  
  <pre><code>var path = require("path"),
      _ = require("underscore"),
      fs = require("fs"),
      variables = fs.readFileSync(path.resolve(__dirname, ".env"), "utf8");
  </code></pre>
  
  <p>At this point I have a string containing something like this:</p>
  
  <pre><code>NODE_ENV=development
  PORT=8080
  </code></pre>
  
  <p>I would like to convert that string into an object so I can read it like this:</p>
  
  <pre><code>{
      NODE_ENV: "development",
      PORT: 8080
  }
  </code></pre>
  
  <p>I'm not sure how I could do it. I was thinking of Regex but I have no clue how to read line by line. Or how about the type of the variable ? Can I detect if it's a string or number ( I was just thinking to see if there are numbers only it means it's a number ? ) ?</p>