Does X/file.ext exist? Does X/file.ext.js exist? Does X/file.ext/index.js exist? Else, throw
542555
function resolveModule(cwd, dir, filename) {
	dir = pathJoin(cwd, dir);

	var filepath = pathJoin(dir, filename);
	var resolved = require.resolve(filepath);

	return resolved && {
		cwd: cwd,
		dir: dir,
		path: resolved
	};
}
63697
function existence ( filepath ) {
		var does = grunt.file.exists ( filepath );
		if ( !does ) {
			grunt.log.warn ( filepath + " not found." );
		}
		return does;
	}
1124629
function writeJs(source, js, base) {
  var filename = path.basename(source, path.extname(source)) + '.js'
  var srcDir   = path.dirname(source)
  var baseDir  = srcDir.substring(base.length)
  var dir      = options.output ? path.join(options.output, baseDir) : srcDir
  var jsPath   = path.join(dir, filename)
  var compile  = function() {
    fs.writeFile(jsPath, js, function(err) {
      if(options.compile && options.watch) console.log("Compiled " + source)
    })
  }
  fs.exists(dir, function(exists) {
    exists ? compile() : exec("mkdir -p " + dir, compile)
  })
}
560405
def isexec(path):
    '''
    
    '''
    return os.path.isfile(path) and os.access(path, os.X_OK)
1342320
function exp(cmd, confdir) {
  return function (files, opt) {
    var defaultOpt = {
      cwd: process.cwd()
    };
    opt = append(defaultOpt, opt);

    if (typeof files == 'string')
      files = [ files ];

    require(path.resolve(confdir, cmd + '.js'))(files, opt);
  };
}
291231
function defaultWindowsLocation() {
  var files = [
    process.env['PROGRAMFILES'] || 'C:\\Program Files',
    process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)'
  ].map(function(prefix) {
    return path.join(prefix, 'Mozilla Firefox\\firefox.exe');
  });
  return io.exists(files[0]).then(function(exists) {
    return exists ? files[0] : io.exists(files[1]).then(function(exists) {
      return exists ? files[1] : null;
    });
  });
}
1083643
def set_extension(self, ext):
        
        path = self._filename.split("/")
        parts = path[-1].split(".")
        if len(parts) == 1:
            parts.append(ext)
        else:
            parts[-1] = ext

        path[-1] = ".".join(parts)
        return File("/".join(path))
655701
def dir_has_index?(relative_path)
      relative_path << "/" unless relative_path.end_with? "/"
      regex = %r!^#{Regexp.escape(relative_path)}#{INDEX_REGEX}!i
      (site.pages + site.static_files).any? { |file| file.url =~ regex }
    end
1279009
def has_extensions(self, *exts):
        """"""
        file_ext = splitext(self.filename)[1]
        file_ext = file_ext.lower()

        for e in exts:
            if file_ext == e:
                return True
        return False
186088
def files_with_exts(root='.', suffix=''):
    
    return (os.path.join(rootdir, filename)
            for rootdir, dirnames, filenames in os.walk(root)
            for filename in filenames
            if filename.endswith(suffix))
968963
function startForeverWithIndex( index, doneCB ) {
  log( 'Attempting to start ' + index + ' as daemon.');

  var config;
  var appendConfig = function(prop, value) {
    log('Adding to config: ' + prop + ', ' + value);
    if(value !== undefined) {
      config[prop] = value;
    }
  };
  done = doneCB || this.async();
  findProcessWithIndex( index, function(process) {
    // if found, be on our way without failing.
    if( typeof process !== 'undefined' ) {
      warn( index + ' is already running.');
      log( forever.format(true, [process]) );
      done();
    }
    else {
      gruntRef.file.mkdir(logDir);
      // 'forever start -o out.log -e err.log -c node -a -m 3 index.js';
      config = {
        command: commandName,
        append: true,
        max: 3,
        killSignal: killSignal
      };
      appendConfig('errFile', errFile);
      appendConfig('outFile', outFile);
      appendConfig('logFile', logFile);
      forever.startDaemon( index, config );
      log( 'Logs can be found at ' + logDir + '.' );
      done();
    }
  });
}
2705
function existDir(getDir) {
        fs.exists(getDir, (exists) => {
            if (exists) {
                existDir(`${dir}/${getVersion()}`);
            } else {
                callBack(_baseVersion.join('.'));
            }
        });
    }
992610
function (dirs, done) {
    var self = this;
    utils.findExtensions(dirs, function (err, extensions) {
      if (err) return done(err);

      for (var i = 0; i < extensions.length; i++) {
        extensions[i].type = extensions[i].type || 'basic';
        extensions[i].id = extensions[i].id.toLowerCase();
        if (RESERVED.indexOf(extensions[i].id) !== -1) {
          return done(new Error('Extension id "' + extensions[i].id + '" is reserved. Your plugins are misconfigured.'));
        }
        if (self.ids[extensions[i].id]) {
          // XXX should we die hard, ignore, or warn?
          return done(new Error('Duplicate extension id! Your plugins are misconfigured.'));
        }
        self.ids[extensions[i].id] = true;
        self.extensions[extensions[i].type][extensions[i].id] = extensions[i];
      }
      done();
    });
  }
259197
function fileExists(file_path) {
  try {
    var stats = fs.statSync(file_path);
    if (stats.isFile()) {
      return true;
    }
  } catch (e) {
  }
  return false;
}
1215973
function fileExists(fileName) {
        if (!fileName) {
            return false;
        }

        var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
        return fs.existsSync(filePath);
    }
1272893
def extant_file(x):
    
    if not os.path.exists(x):
        raise argparse.ArgumentError("{0} does not exist".format(x))
    return x
924124
function findExcess(dir, shrinkwrap, opts, scope, cb) {  // jshint ignore:line
    fs.readdir(dir, function (err, files) {
        if (err) {
            return cb(err);
        }

        parallel(files.map(function (file) {
            return validateExcess.bind(null, dir, file, shrinkwrap, opts,
              scope);
        }), function (err, excessFiles) {
            if (err) {
                return cb(err);
            }
            return cb(null, flatten(excessFiles || []).filter(Boolean));
        });
    });
}