path.js
function realRequirPath(filePath) {
  // console.log('realRequirPath:filePath: ' + filePath);
  var jsFilePath = filePath + '.js';
  if (fs.existsSync(filePath)) {
    if (fs.statSync(filePath).isDirectory()) {
      jsFilePath = filePath + '.js';
      if (fs.existsSync(jsFilePath)) {
        return jsFilePath;
      } else {
        jsFilePath = path.join(filePath, 'index.js');
      }
      // console.log('realRequirPath:jsFilePath: ' + jsFilePath);
    } else if (fs.statSync(filePath).isFile()) {
      return filePath;
    } else {
      return null;
    }
  } else {
    jsFilePath = filePath + '.js';
    // console.log('realRequirPath:filePath: ' + filePath);
  }

  if (fs.existsSync(jsFilePath)) {
    // console.log('realRequirPath:filePath: ' + filePath);
    return jsFilePath;
  } else {
    return null;
  }
}
function realRequirPath(filePath) {
  // console.log('realRequirPath:filePath: ' + filePath);
  var jsFilePath = filePath + '.js';
  if (fs.existsSync(filePath)) {
    if (fs.statSync(filePath).isDirectory()) {
      jsFilePath = filePath + '.js';
      if (fs.existsSync(jsFilePath)) {
        return jsFilePath;
      } else {
        jsFilePath = path.join(filePath, 'index.js');
      }
      // console.log('realRequirPath:jsFilePath: ' + jsFilePath);
    } else if (fs.statSync(filePath).isFile()) {
      return filePath;
    } else {
      return null;
    }
  } else {
    jsFilePath = filePath + '.js';
    // console.log('realRequirPath:filePath: ' + filePath);
  }

  if (fs.existsSync(jsFilePath)) {
    // console.log('realRequirPath:filePath: ' + filePath);
    return jsFilePath;
  } else {
    return null;
  }
}
function realRequirPath ( filePath ) { // console.log('realRequirPath:filePath: ' + filePath); var jsFilePath = filePath + '.js' ; if ( fs . existsSync ( filePath ) ) { if ( fs . statSync ( filePath ) . isDirectory ( ) ) { jsFilePath = filePath + '.js' ; if ( fs . existsSync ( jsFilePath ) ) { return jsFilePath ; } else { jsFilePath = path . join ( filePath , 'index.js' ) ; } // console.log('realRequirPath:jsFilePath: ' + jsFilePath); } else if ( fs . statSync ( filePath ) . isFile ( ) ) { return filePath ; } else { return null ; } } else { jsFilePath = filePath + '.js' ; // console.log('realRequirPath:filePath: ' + filePath); } if ( fs . existsSync ( jsFilePath ) ) { // console.log('realRequirPath:filePath: ' + filePath); return jsFilePath ; } else { return null ; } }
get real required file path

module to module.js or module/index.js

@param filePath
@returns {*}
get real required file path