function option(data) {
    console.log('your choice: ', data);

    var filename = files[Number(data)];
    var filepath = __dirname + '/' + filename;
    if(!filename) {
      stdout.write('    \033[31m Enter your choice! \033[39m');

    } else {
      stdin.pause();
      if(stats[Number(data)].isDirectory()) {
        fs.readdir(filepath, function(err, files) {
          console.log('');
          console.log('   （' + files.length + ' files）');
          files.forEach(function(file) {
            console.log('   -  ' + file);

          });
          console.log('');

        })
      } else {
        fs.readFile(filepath, 'utf8', function(err, data) {
          console.log('');
          console.log('\033[90m' + data + '\033[39m');

        });
      }

    }
  }
// called with the option supplied by the user
called with the option supplied by the user
called with the option supplied by the user
function option(data) {
    console.log('your choice: ', data);
    var filename = files[Number(data)];
    var filepath = __dirname + '/' + filename;
    if(!filename) {
      stdout.write('    \033[31m Enter your choice! \033[39m');
    } else {
      stdin.pause();
      if(stats[Number(data)].isDirectory()) {
        fs.readdir(filepath, function(err, files) {
          console.log('');
          console.log('   （' + files.length + ' files）');
          files.forEach(function(file) {
            console.log('   -  ' + file);
          });
          console.log('');
        })
      } else {
        fs.readFile(filepath, 'utf8', function(err, data) {
          console.log('');
          console.log('\033[90m' + data + '\033[39m');
        });
      }
    }
  }
function option ( data ) { console . log ( 'your choice: ' , data ) ; var filename = files [ Number ( data ) ] ; var filepath = __dirname + '/' + filename ; if ( ! filename ) { stdout . write ( '    \033[31m Enter your choice! \033[39m' ) ; } else { stdin . pause ( ) ; if ( stats [ Number ( data ) ] . isDirectory ( ) ) { fs . readdir ( filepath , function ( err , files ) { console . log ( '' ) ; console . log ( '   （' + f les.l e ngth + ' files）'); files . forEach ( function ( file ) { console . log ( '   -  ' + file ) ; } ) ; console . log ( '' ) ; } ) } else { fs . readFile ( filepath , 'utf8' , function ( err , data ) { console . log ( '' ) ; console . log ( '\033[90m' + data + '\033[39m' ) ; } ) ; } } }
called with the option supplied by the user
called with the option supplied by the user