forked from electron/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpack.js
More file actions
executable file
·39 lines (33 loc) · 1.22 KB
/
Copy pathpack.js
File metadata and controls
executable file
·39 lines (33 loc) · 1.22 KB
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
37
38
39
const fs = require('fs');
const path = require('path');
const yaml = require('yaml');
const dates = require('../meta/dates.json');
const parseGitHubUrl = require('github-url-to-object');
const apps = [];
fs.readdirSync(path.join(__dirname, '../apps'))
.filter((filename) => {
return fs.statSync(path.join(__dirname, `../apps/${filename}`)).isDirectory();
})
.forEach((slug) => {
const yamlFile = path.join(__dirname, `../apps/${slug}/${slug}.yml`);
const meta = yaml.parse(fs.readFileSync(yamlFile, 'utf-8'));
if (meta.disabled) {
return;
}
const app = Object.assign({ slug: slug }, meta, {
icon: `${slug}-icon.png`,
icon32: `${slug}-icon-32.png`,
icon64: `${slug}-icon-64.png`,
icon128: `${slug}-icon-128.png`,
icon256: `${slug}-icon-256.png`,
date: dates[slug],
});
// Delete website if it's the same URL as repository
const parsedWebsite = parseGitHubUrl(app.website);
const parsedRepo = parseGitHubUrl(app.repository);
if (parsedWebsite && parsedRepo && parsedWebsite.https_url === parsedRepo.https_url) {
delete app.website;
}
apps.push(app);
});
fs.writeFileSync(path.join(__dirname, '../index.json'), JSON.stringify(apps, null, 2));