forked from electron/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.js
36 lines (33 loc) · 901 Bytes
/
colors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs')
const path = require('path')
const getImageColors = require('get-image-colors')
const apps = require('../lib/raw-app-list')()
const colors = {}
console.log('Extracting color palettes from app icons...')
// Prevent superficial diffs in the file by adding sorted keys first
apps.forEach(app => {
colors[app.slug] = null
})
Promise.all(
apps
.filter(app => fs.existsSync(app.iconPath))
.map(app => {
return getImageColors(app.iconPath).then(iconColors => {
colors[app.slug] = iconColors.map(color => color.hex())
return Promise.resolve(true)
})
.catch(error => {
console.log(`problem with ${app.slug} icon: ${app.iconPath}`)
console.error(error)
})
})
)
.then(apps => {
fs.writeFileSync(
path.join(__dirname, '../meta/colors.json'),
JSON.stringify(colors, null, 2)
)
})
.catch(error => {
console.error(error)
})