hyper-folder-icon
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -7,3 +7,7 @@ const Icns = require('apple-icns'); | ||
const gnomeIcon = require('./gnome'); | ||
const _p = require('promisfy'); | ||
const exists = _p.promisfyNoError(fs.exists); | ||
const readFile = _p.promisfy(fs.readFile); | ||
const RESOURCEFORK = 'rf'; | ||
@@ -46,4 +50,2 @@ const APPFOLDER = 'apf'; | ||
} | ||
} else if (!fs.existsSync(folder + '/Icon\r' )) { | ||
this.type = VOLUMEFOLDER; | ||
} | ||
@@ -99,14 +101,38 @@ } | ||
return new Promise((resolve,reject) => { | ||
let file = new resourceFork(this.folder + '/Icon\r'); | ||
file.read() | ||
.then(() => { | ||
let buffer = Buffer.from(file.resources['icns'][49081].data.buffer,260); | ||
let icon = new Icns(buffer); | ||
let _findIcon = (folder) => new Promise(async (resolve,reject) => { | ||
iconReading(icon) | ||
.then((ret) => resolve(ret)) | ||
.catch((err) => reject(err)); | ||
}) | ||
.catch((error) => reject(error)); | ||
while (!await exists(folder + '/Icon\r')) { | ||
folder = folder.split('/').slice(0,-1).join('/'); | ||
if (folder == "") { | ||
break; | ||
} | ||
} | ||
if (folder == "") { | ||
const data = await readFile('/.VolumeIcon.icns').catch(err => reject(err)); | ||
let icon = new Icns(data); | ||
const ret = iconReading(icon).catch(err => reject(err)); | ||
resolve(ret); | ||
} else { | ||
let file = new resourceFork(folder + '/Icon\r'); | ||
try { | ||
await file.read(); | ||
let buffer = Buffer.from(file.resources['icns'][49081].data.buffer,260); | ||
let icon = new Icns(buffer); | ||
const ret = await iconReading(icon); | ||
resolve(ret); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
} | ||
}); | ||
_findIcon(this.folder.slice()) | ||
.then(ret => resolve(ret)) | ||
.catch(error => reject(error)); | ||
}); | ||
@@ -113,0 +139,0 @@ break; |
{ | ||
"name": "hyper-folder-icon", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Use folder icons in MacOS and Windows with Hyper", | ||
@@ -32,4 +32,5 @@ "main": "./index.js", | ||
"plist": "^3.0.1", | ||
"promisfy": "^1.1.4", | ||
"resourceforkjs": "0.0.4" | ||
} | ||
} |
@@ -13,3 +13,4 @@ hyper-folder-icon | ||
- Show icon of current folder if custom icon has been applied to the folder | ||
- Show Volume icon of the HD if the folder does not have a custom icon | ||
- <=1.4.0: ~~Show Volume icon of the HD if the folder does not have a custom icon~~ | ||
- ^1.5.0 Show icon of any of the parent folders. If there is no, show the Volume icon. | ||
- Show Volume icon of additional Volumes if a custom icon has been applied to the Volume | ||
@@ -19,3 +20,3 @@ - Show App icon if inside of the .app folder | ||
- Integrates with hyper-tab-touchbar showing the icons in the MacBook Pro's TouchBar | ||
- Integrates with [hyper-tab-touchbar](https://github.com/moimart/hyper-tab-touchbar) showing the icons in the MacBook Pro's TouchBar | ||
@@ -22,0 +23,0 @@  |
22488
547
48
9
+ Addedpromisfy@^1.1.4
+ Addedpromisfy@1.2.0(transitive)