title: Nodejs get absolute path relative to process.cwd()
body: <p>So I have the following code block:</p>
  
  <pre><code>#!/usr/bin/env node
  
  const path = require('path');
  const yargs = require('yargs').argv;
  const ghpages = require('gh-pages');
  const randomstring = require("randomstring");
  
  const dirName = randomstring.generate({
    length: 12,
    charset: 'alphabetic'
  });
  
  console.log(__dirname, dirName, process.cwd(), yargs.directory, yargs.branch);
  
  ghpages.publish(path.join(process.cwd(), yargs.directory), {
    branch: yargs.branch,
    clone: `../../../../tmp/${dirName}`
  }, () =&gt; {
    console.log('removing');
  });
  </code></pre>
  
  <p>This requires an absolute path to the <code>clone</code> location.</p>
  
  <p>Obviously I have hard coded it at the moment for testing but what I want to do is get the absolute path to <code>/tmp/</code> from the <code>process.cwd()</code>.</p>
  
  <p>So basically what I want is if I ran the script in <code>/home/otis</code> <code>../../../../tmp/${dirName}</code> would become <code>../../tmp/${dirName}</code> so I need to generate the path based on the <code>process.cwd()</code></p>
  
  <p>Any ideas?</p>
  
  <p>Cheers/</p>