Find out what uid the docker machine is using
@param {string} bindPath
@return {boolean}
548560
function getDockerUid(bindPath) {
  const options = [
    'run',
    '--rm',
    '-v',
    `${bindPath}:/test`,
    'alpine',
    'stat',
    '-c',
    '%u',
    '/bin/sh'
  ];
  const ps = dockerCommand(options);
  return ps.stdout.trim();
}
589129
function hasIt(path) {
            var areITFound = false;
            if (path.node.name === IT) {
              return true;
            }
            path.traverse({
              Identifier: function Identifier(path) {
                if (path.node.name === IT) {
                  areITFound = true;
                }
              }
            });
            return areITFound;
          }
585806
def _check_yaml_and_paths(ymlfilepath, yamldefs):
        
        relpath = os.path.relpath(ymlfilepath)
        if '/' not in relpath:
            relpath = './%s' % relpath
        pathroot = os.path.abspath(os.path.dirname(ymlfilepath))

        for imagename, defn in iteritems(yamldefs):
            if imagename == '_SOURCES_':
                yamldefs['_SOURCES_'] = [os.path.relpath(_get_abspath(pathroot, p))
                                         for p in yamldefs['_SOURCES_']]
                continue
            elif imagename in SPECIAL_FIELDS:
                continue

            for key in ('build_directory', 'FROM_DOCKERFILE', 'ignorefile'):
                if key in defn:
                    defn[key] = _get_abspath(pathroot, defn[key])

            if 'copy_from' in defn:
                if not isinstance(defn['copy_from'], dict):
                    raise errors.ParsingFailure((
                            'Syntax error in file "%s": \n' +
                            'The "copy_from" field in image definition "%s" is not \n' 
                            'a key:value list.') % (ymlfilepath, imagename))
                for otherimg, value in defn.get('copy_from', {}).items():
                    if not isinstance(value, dict):
                        raise errors.ParsingFailure((
                            'Syntax error in field:\n'
                            '     %s . copy_from . %s\nin file "%s". \n'
                            'All entries must be of the form "sourcepath: destpath"')%
                                 (imagename, otherimg, ymlfilepath))

            # save the file path for logging
            defn['_sourcefile'] = relpath

            if 'ignore' in defn and 'ignorefile' in defn:
                raise errors.MultipleIgnoreError(
                        'Image "%s" has both "ignore" AND "ignorefile" fields.' % imagename +
                        ' At most ONE of these should be defined')

            if 'secret_files' in defn and not defn.get('squash', True):
                raise errors.ParsingFailure(
                        "Step '%s' defines secret_files, so 'squash' cannot be set to 'false'"
                        % imagename)

            if defn.get('secret_files', None) and defn.get('copy_from', False):
                raise errors.ParsingFailure(
                        '`secret_files` currently is not implmemented to handle `copy_from`'
                        ' (step %s)' % imagename)

            for key in defn:
                if key not in RECOGNIZED_KEYS:
                    raise errors.UnrecognizedKeyError(
                            'Field "%s" in image "%s" in file "%s" not recognized' %
                            (key, imagename, relpath))
186343
def _get_uid(name):
    """"""
    if getpwnam is None or name is None:
        return None
    try:
        result = getpwnam(name)
    except KeyError:
        result = None
    if result is not None:
        return result[2]
    return None
206725
function resourcePath(resourceId, dest = '') {
  const subPath = idKeys(resourceId);
  // Remove first item because it is the "resource type"
  // If there _is_ only one item in the ID, it will be left alone
  // To serve as the filename.
  if (subPath.length !== 0 && subPath.length > 1) {
    subPath.shift();
  }
  const filename = subPath.pop() + '.html';
  const outputPath = path.normalize(
    path.join(dest, subPath.join(path.sep), filename)
  );
  return outputPath;
}
660108
function detectPorting(target) {
    const PORTING_DEV_DIR = path.join(config.dir.src, config.dir.porting);
    const PLATFORMS_ROOT = path.join(__dirname, '..', 'platforms');

    const valid_targets = [];

    // valid porting
    if (!fs.existsSync(PORTING_DEV_DIR)) {
        return valid_targets;
    }

    const temp_targets = [];

    if (null == target || 'all' === target) {
        temp_targets.push('dev');
        fs.readdirSync(PLATFORMS_ROOT)
        .forEach((find) => {
            const findPath = path.join(PLATFORMS_ROOT, find);
            if (fs.statSync(findPath).isDirectory()) {
                temp_targets.push(find);
            }
        });
    } else {
        const _targets = target.split(',');
        _targets.forEach((_tgt) => {
            temp_targets.push(_tgt);
        });
    }

    temp_targets.forEach((candidate) => {
        if ('dev' === candidate) {
            valid_targets.push('dev');
        } else {
            if (fs.existsSync(path.join('platforms', candidate, config.dir.porting))) {
                valid_targets.push(candidate);
            }
        }
    });

    return valid_targets;
}
832442
function isCandidate(modulePath) {
        modulePath = modulePath || '';
        var pathParts = modulePath.split(delim);
        return (pathParts.length === 4 &&
                pathParts[0] === 'app' &&
                uiTypes.indexOf(pathParts[2]) >= 0);
    }
621858
function getDotAWSMobileDirPath(projectPath)
{
    return path.normalize(path.join(getAWSMobileJSDirPath(projectPath), awsmobilejsConstant.DotAWSMobileSubDirName))
}
558837
function isAppDir_p(dirPath) {
      var deferred = Q.defer();
      fs.exists(dirPath, function(exists) {
        if (!exists)
          deferred.resolve({
            exists: false, 
            isApp: false, 
            isRmd: false, 
            index: false
          });
        else {
          deferred.resolve(
            Q.nfcall(fs.readdir, dirPath)
            .then(
              function(entries) {
                var app = _.find(entries, function(entry) {
                  return /^server\.r$/i.test(entry);
                });
                var singleApp = _.find(entries, function(entry) {
                  return /^app\.r$/i.test(entry);
                });
                var rmd = _.find(entries, function(entry) {
                  return /\.rmd$/i.test(entry);
                });
                var indexRmd = _.find(entries, function(entry) {
                  if (/^index\.rmd$/i.test(entry)){
                    return entry;
                  }
                  return false;
                });
                var indexHtm = _.find(entries, function(entry) {
                  if (/index\.htm(l)?$/i.test(entry)){
                    return entry;
                  }
                  return false;
                });

                // Give priority to an Rmd index, the fall back to an html index
                return {
                  exists: true, 
                  isApp: (!!app || !!singleApp), 
                  isRmd: !!rmd, 
                  indexType: indexRmd ? 'rmd' : indexHtm ? 'html' : null,
                  indexPath: indexRmd || indexHtm
                };
              },
              function(err) {
                if (err.code == 'ENOTDIR') {
                  return {
                    exists: false, 
                    isApp: false, 
                    isRmd: false, 
                    indexType: null
                  };
                }
                else {
                  logger.error('Error reading dir: ' + err.message);
                  return {
                    exists: true, 
                    isApp: false, 
                    isRmd: false, 
                    indexType: null
                  };
                }
              }
            )
          );
        }
      });

      return deferred.promise;
    }
1158803
function(path) {
    var bind = path;
    if (process.platform === 'win32') {
      bind = path.replace(/\\/g, '/').replace('C:/', 'c:/');
    }
    return bind;
  }
1275016
function resolveSync (iconPath) {
  var path = resolve(iconPath)
  var stat = fs.statSync(path)

  if (stat.isDirectory()) {
    throw createIsDirError(path)
  }

  return path
}
897297
function isTypeOf(path, typePath) {
            var node = _getNode(path);

            if (node) {
                return state.core.isTypeOf(node, typePath);
            }

            return false;
        }
377593
function isExecutable(path) {
    if (!fs_1.existsSync(path))
        return false;
    try {
        var stats = fs_1.statSync(path);
        if (chek_1.isWindows()) { // just return if is file, not ideal.
            return stats && stats.isFile();
        }
        else {
            var hasGroup = stats.gid
                ? process.getgid && stats.gid === process.getgid()
                : true;
            var hasUser = stats.uid
                ? process.getuid && stats.uid === process.getuid()
                : true;
            // just didn't want additional depend.
            // see https://github.com/kevva/executable/blob/master/index.js#L13
            return Boolean((stats.mode & parseInt('0001', 8)) ||
                ((stats.mode & parseInt('0010', 8)) && hasGroup) ||
                ((stats.mode & parseInt('0100', 8)) && hasUser));
        }
    }
    catch (ex) {
        return false;
    }
}
161001
function(filePath){
  var parts = filePath.split('/');
  if(parts.length > 0){
    var id = parts.pop();
    return {
      id: id,
      path: parts.join('/')
    }
  } else {
    return false;
  }
}
1318655
function _findProjectPathById(id) {
  logger.debug('_findProjectPathById');
  logger.debug(id);
  var projectPathToReturn;
  var workspaces = config.get('mm_workspace');
  if (!_.isArray(workspaces)) {
    workspaces = [workspaces];
  }
  logger.silly(workspaces);
  _.each(workspaces, function(workspacePath) {
    // /foo/bar/project
    // /foo/bar/project/config/.settings
    logger.silly(workspacePath);
    var projectPaths = util.listDirectories(workspacePath);
    logger.silly(projectPaths);
    _.each(projectPaths, function(projectPath) {
      var settingsPath = path.join(projectPath, 'config', '.settings');
      if (fs.existsSync(settingsPath)) {
        var settings = util.getFileBody(settingsPath, true);
        if (settings.id === id) {
          projectPathToReturn = projectPath;
          return false;
        }
      }
    });
  });
  return projectPathToReturn;
}
536420
function getId(rootFolder) {
    return new Promise((resolve, reject) => {
        const dir = path.join(rootFolder, constants.META_DIR, constants.META_ID);
        fs.readFile(dir, 'utf8', (err, id) => {
            if (err) {
                reject(err);
                return;
            } else {
                resolve(id);
                return;
            }
        });
    });
}
1241017
def get_bind_modules(verbose=False):
    
    builtin_path = os.path.join(module_root_path, "bind")
    searchpaths = config.bind_module_path + [builtin_path]
    bindnames = {}

    for path in searchpaths:
        if verbose:
            print "searching %s..." % path
        if not os.path.isdir(path):
            continue

        for filename in os.listdir(path):
            fpath = os.path.join(path, filename)
            fname, ext = os.path.splitext(filename)
            if os.path.isfile(fpath) and ext == ".py" \
                    and not fname.startswith('_'):
                bindnames[fname] = fpath

    return bindnames