Make sure the bin directory for the current version
is in `$PATH`.
@param {String} directory

@todo (imlucas): :axe: env helper from `mongodb-js/mj`
and use it here.
775302
function addToPath(directory) {
  var srcs = process.env.PATH.split(delimiter);
  if (srcs.indexOf(directory) === -1) {
    srcs.unshift(directory);
    process.env.PATH = srcs.join(delimiter);
    debug('added `%s` to $PATH and its now `%s`',
      directory, process.env.PATH);
  }
}
1046515
function _mkdir($path, $mode = 0777)
    {
        $old = umask(0);
        $res = @mkdir($path, $mode);
        umask($old);

        return $res;
    }
350177
async function makeDir(dir) {
    const res = await makePromise(fs.mkdir, dir, dir)
    return res
}
907476
function recursiveMkDir(dir) {
    if (!fs.existsSync(dir)) {
        recursiveMkDir(path.dirname(dir));
        fs.mkdirSync(dir);
    }
}
483926
static function chdir($dir, $callback = null, $argv = array())
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException("$dir does not exist.");
        }

        $cwd = getcwd();
        chdir($dir);

        if (null === $callback) {
            return;
        }

        $returnValue = call_user_func_array($callback, $argv);

        chdir($cwd);
        return $returnValue;
    }
1058573
def ensure_dir(directory: str) -> None:
    """"""
    if not os.path.isdir(directory):
        LOG.debug(f"Directory {directory} does not exist, creating it.")
        os.makedirs(directory)
533880
function mkDir(p, mode = 0777) {
    if (fs.existsSync(p)) {
        chmod(p, mode);
        return true;
    } else {
        if (mkDir(path.dirname(p))) {
            fs.mkdirSync(p, mode);
            return true;
        }
    }
}
1269986
function (path) {
    if (fs.existsSync(path) && fs.statSync(path).isDirectory()) {
      return true;
    }
    return false;
  }
1263731
function mkpath(path) {
    var dirs = path.split(PATH.sep);
    var _path = '';
    var winDisk = /^\w{1}:\\$/;

    dirs.forEach(function(dir) {
        dir = dir || PATH.sep;
        if (dir) {
            _path = _path ? PATH.join(_path, dir) : dir;
            // fs.mkdirSync('/') raises EISDIR (invalid operation) exception on OSX 10.8.4/node 0.10
            // fs.mkdirSync('D:\\') raises EPERM (operation not permitted) exception on Windows 7/node 0.10
            // not tested in other configurations
            if (_path === '/' || winDisk.test(PATH.resolve(dir))) {
                return;
            }
            // @see https://github.com/veged/borschik/issues/90
            try {
                fs.mkdirSync(_path);
            } catch(e) {
                // ignore EEXIST error
                if (e.code !== 'EEXIST') {
                    throw new Error(e)
                }
            }
        }
    });
}
32008
function CrosswalkDir(path) {

    this._path = path;
    this._root = "./";

    var versionFilePath = Path.join(path, "VERSION");
    if (ShellJS.test("-f", versionFilePath)) {
        this._version = Version.createFromFile(versionFilePath);
    } else {
        this._version = Version.createFromPath(path);
    }

    if (!this._version) {
        throw new Error("Failed to determine crosswalk version");
    }
}
987054
function getDirectoryTree(dir) {
    const items = [];
    return new Promise(function(resolve) {
        fs.walk(dir)
        .on('data', function (item) {
            items.push(item.path);
        })
        .on('end', function () {
            resolve(items);
        });
    });
}
927802
function initDir(path, title) {
  if (fis.util.exists(path)) {
    if (!fis.util.isDir(path)) {
      fis.log.error('unable to set path[%s] as %s directory.', path, title);
    }
  } else {
    fis.util.mkdir(path);
  }
  path = fis.util.realpath(path);
  if (path) {
    return path;
  } else {
    fis.log.error('unable to create dir [%s] for %s directory.', path, title);
  }
}
721962
function makeFolder(path, cb) {
  if (cb) {
    fs.mkdir(path, function (err) {
      if (err && err.code != 'EEXIST') {
        throw err;
      }
      cb();
    });
  }
}
1151673
def _mkdir(path):
    
    try:
        os.mkdir(path)
    except OSError as e:
        if e.errno == 17:
            show_error("ABORTING: Directory {0} already exists.".format(path))
        else:
            show_error("ABORTING: OSError {0}".format(e))
        sys.exit()
904616
function isValidDir(dir) {
    var fs = require("fs");
    try {
        return fs.statSync(dir).isDirectory();
    } catch (err) {
        return false;
    }
}
856071
function(location) {
  var found = false;

  while(!found) {
    if (exists(location + '/package.json')) {
      found = location;
    } else if (location !== '/') {
      location = path.dirname(location);
    } else {
      return false;
    }
  }

  return location;
}
113328
function mk(dir) {
      var absDir = path.resolve(dir);
      if (!fs.existsSync(absDir)) {
        try {
          fs.mkdirSync(absDir);
        }
        catch (e) {
          mk(path.dirname(absDir));
          fs.mkdirSync(absDir);
        }
      }
    }