bayleeadamoss / zazu-file-finder

A file finder for Zazu.
18 stars 11 forks source link

Make it for both mac and linux usable #17

Closed JeroenBoersma closed 7 years ago

JeroenBoersma commented 7 years ago

It could create some double lookup, but I think it should be best of both worlds

bayleedev commented 7 years ago

I reload zazu with these changes,rm data/applications.json, then wait for the file to be created. Once it's created it's contents are an empty array. ]:

Maybe some os specific logic?

diff --git a/lib/file.js b/lib/file.js
index 0978d9e..8e9e5af 100644
--- a/lib/file.js
+++ b/lib/file.js
@@ -46,6 +46,9 @@ class File {
   isDirectory () {
     const isDirectory = this.stats.isDirectory()
     const isSymbolicLink = this.stats.isSymbolicLink()
+    if (process.platform === 'darwin') {
+      return isDirectory && !isSymbolicLink && !this.isApp()
+    }
     return isDirectory && !isSymbolicLink
   }
JeroenBoersma commented 7 years ago

os specific in isDirectory too, hmm, will work out for now... Maybe we have too reconsider some codeparts for long term...

Also strange that it empties your applications.json because isApp should never go into that last bit of code

bayleedev commented 7 years ago

We could create a isMacApp method.

return isDirectory && !isSymbolicLink && !this.isMacApp()
isMacApp () {
  return process.platform === 'darwin' && this.isApp()
}

If you think that's any better?

JeroenBoersma commented 7 years ago

I think that would mac ;) it more clear...

Maybe even refactor isApp()...

isApp(){
    return isAppMac() || isAppLinux() || isAppWindows();
}
isAppMac() {}
isAppLinux(){}
isAppWindows() {}

isDirectory && !isSymbolicLink && !this.isAppMac()
bayleedev commented 7 years ago

Thanks!