lib/extractors/doc-osx.js
function extractText( filePath, options, cb ) {
  var result = ''
    , error = null
    , textutil = spawn( 'textutil', ['-convert', 'txt', '-stdout', filePath] )
    ;

  textutil.stdout.on( 'data', function( buffer ) {
    result += buffer.toString();
  });

  textutil.stderr.on( 'error', function( buffer ) {
    if ( !error ) {
      error = '';
    }
    error += buffer.toString();
  });

  textutil.on( 'close', function( /* code */ ) {
    if ( error ) {
      error = new Error( 'textutil read of file named [[ ' +
        path.basename( filePath ) + ' ]] failed: ' + error );
      cb( error, null );
      return;
    }
    cb( null, result.trim() );
  });
}
function extractText( filePath, options, cb ) {
  var result = ''
    , error = null
    , textutil = spawn( 'textutil', ['-convert', 'txt', '-stdout', filePath] )
    ;

  textutil.stdout.on( 'data', function( buffer ) {
    result += buffer.toString();
  });

  textutil.stderr.on( 'error', function( buffer ) {
    if ( !error ) {
      error = '';
    }
    error += buffer.toString();
  });

  textutil.on( 'close', function( /* code */ ) {
    if ( error ) {
      error = new Error( 'textutil read of file named [[ ' +
        path.basename( filePath ) + ' ]] failed: ' + error );
      cb( error, null );
      return;
    }
    cb( null, result.trim() );
  });
}
function extractText ( filePath , options , cb ) { var result = '' , error = null , textutil = spawn ( 'textutil' , [ '-convert' , 'txt' , '-stdout' , filePath ] ) ; textutil . stdout . on ( 'data' , function ( buffer ) { result += buffer . toString ( ) ; } ) ; textutil . stderr . on ( 'error' , function ( buffer ) { if ( ! error ) { error = '' ; } error += buffer . toString ( ) ; } ) ; textutil . on ( 'close' , function ( /* code */ ) { if ( error ) { error = new Error ( 'textutil read of file named [[ ' + path . basename ( filePath ) + ' ]] failed: ' + error ) ; cb ( error , null ) ; return ; } cb ( null , result . trim ( ) ) ; } ) ; }
textutil -convert txt -stdout foo.doc
textutil - convert txt - stdout foo . doc