ronomon / opened

Check if a file is open in another application on Windows, macOS and Linux.
MIT License
16 stars 7 forks source link

Fix example code in ReadMe #3

Closed popod closed 6 years ago

popod commented 6 years ago

Your example code does not works in my Mac (High Sierra and node v8.6.0):

var Opened = require('@ronomon/opened');
var paths = ['./test.txt'];
Opened.files(paths,
  function(error, hashTable) {
    if (error) throw error;
    paths.forEach(
      function(path) {
        console.log(path + ' open=' + hashTable.hasOwnProperty(path));
      }
    );
  }
);

hashTable contain { 'test.txt': true|false } so you should use:

console.log(path + ' open=' + hashTable[path]);

In place of:

console.log(path + ' open=' + hashTable.hasOwnProperty(path));

I've too:

jorangreef commented 6 years ago

Thanks @popod, I did another PR quickly with all your fixes but I didn't want to expose Open.file() in the docs just yet.

Thanks for spotting this, I don't know how I missed it.