Skip to content
This repository was archived by the owner on Apr 9, 2026. It is now read-only.

Commit 986476f

Browse files
committed
Release v4.0.0
2 parents d87824c + cab88f9 commit 986476f

File tree

10 files changed

+235
-184
lines changed

10 files changed

+235
-184
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules/
55
npm-debug.log
66
yarn-error.log
77
yalc.lock
8+
.idea/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/dubnium

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ Simple workflow that allows you to browse and open [Atom](https://atom.io/) proj
44

55
## Requirements
66

7-
- NodeJS 8+
7+
- NodeJS 10+
88
- [Atom Project Manager package](https://atom.io/packages/project-manager)
99
- Alfred 4 with paid [Alfred Powerpack](https://www.alfredapp.com/powerpack)
1010

1111
## Installation
1212

13-
### NPM (preferred)
13+
### Yarn / NPM (preferred)
1414

15-
This workflow can be installed with NPM, as an added bonus you'll get a notification when an update is available!
15+
This workflow can be installed with Yarn or NPM, as an added bonus you'll get a notification when an update is available!
1616

1717
```shell
18+
yarn add -g alfred-atom
19+
# or
1820
npm install -g alfred-atom
1921
```
2022

@@ -24,7 +26,7 @@ Because some dependencies are quite big you have to run `npm install` yourself a
2426

2527
1. Download the latest `Atom.alfredworkflow` from [Packal](http://www.packal.org/workflow/atom) or [GitHub](https://github.com/Cloudstek/alfred-atom/releases) and import it in Alfred.
2628
2. Open Alfred and go to Workflows. Right-click on Atom and click on *"Open in Terminal"*
27-
3. In the terminal, enter `npm install`
29+
3. In the terminal, enter `yarn` or `npm install`.
2830

2931
## Usage
3032

info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Simply type atom and press space to list all projects. Optionally type a search
239239
<string>terminalApp</string>
240240
</array>
241241
<key>version</key>
242-
<string>3.0.4</string>
242+
<string>4.0.0</string>
243243
<key>webaddress</key>
244244
<string>https://github.com/Cloudstek/alfred-atom</string>
245245
</dict>

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "alfred-atom",
3-
"version": "3.0.4",
3+
"version": "4.0.0",
44
"repository": "Cloudstek/alfred-atom",
55
"author": "Maarten de Boer <maarten@cloudstek.nl> (https://cloudstek.nl)",
66
"license": "BSD-2-Clause",
@@ -23,14 +23,14 @@
2323
],
2424
"dependencies": {
2525
"@primer/octicons": "^9.3.1",
26-
"alfred-hugo": "^2.0.5",
26+
"alfred-hugo": "^3.0.1",
2727
"change-case": "^4.1.1",
2828
"color": "^3.1.2",
2929
"cson-parser": "^4.0.3",
30-
"fs-extra": "^8.1.0",
30+
"fs-extra": "^9.0.0",
3131
"glob": "^7.1.6",
3232
"moment": "^2.24.0",
33-
"sharp": "^0.24.0",
33+
"sharp": "^0.25.2",
3434
"untildify": "^4.0.0"
3535
},
3636
"devDependencies": {
@@ -44,7 +44,7 @@
4444
"typescript": "^3.7.2"
4545
},
4646
"engines": {
47-
"node": ">=8"
47+
"node": ">=10"
4848
},
4949
"scripts": {
5050
"clean": "del-cli dist*",

src/icons.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import fs from "fs-extra";
22
import path from "path";
33
import color from "color";
44
import sharp from "sharp";
5-
import { Item } from "alfred-hugo";
5+
import {Item} from "alfred-hugo";
66

7-
import { IconsRebuildOptions, Octicon } from "./types";
7+
import {IconsRebuildOptions, Octicon} from "./types";
88

99
export class Icons {
1010
public static all() {
@@ -87,20 +87,24 @@ export class Icons {
8787
}
8888

8989
// Create icons dir if not exists
90-
fs.ensureDir(path.join(__dirname, "icons"));
90+
await fs.ensureDir(path.join(__dirname, "icons"));
9191

92-
for (const [name, icon] of icons) {
93-
// console.log(iconSize, iconColor.rgb().toString());
92+
let sharpTasks: Promise<sharp.OutputInfo>[];
9493

94+
for (const [name, icon] of icons) {
9595
// Add fill to SVG path
96-
const svgPath = icon.path.replace(/\/\>$/, ` fill="${iconColor.rgb().toString()}" />`);
96+
const svgPath = icon.path.replace(/\/>$/, ` fill="${iconColor.rgb().toString()}" />`);
9797

9898
// Build SVG
9999
const svg = `<svg viewBox="0 0 ${icon.width} ${icon.height}" width="${iconSize}" height="${iconSize}" xmlns="http://www.w3.org/2000/svg">${svgPath}</svg>`;
100100

101-
sharp(Buffer.from(svg))
102-
.png()
103-
.toFile(path.join(iconPath, `${name}.png`));
101+
sharpTasks.push(
102+
sharp(Buffer.from(svg))
103+
.png()
104+
.toFile(path.join(iconPath, `${name}.png`))
105+
);
104106
}
107+
108+
await Promise.all(sharpTasks);
105109
}
106110
}

src/index.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import cson from "cson-parser";
22
import untildify from "untildify";
3-
import { Hugo, Item } from "alfred-hugo";
3+
import {Hugo, Item} from "alfred-hugo";
44

5-
import { Icons } from "./icons";
5+
import {Icons} from "./icons";
66
import * as utils from "./utils";
7-
import { Projects } from "./project";
7+
import {Projects} from "./project";
88

99
const hugo = new Hugo({
1010
checkUpdates: true,
1111
updateNotification: false,
1212
updateSource: "npm",
1313
});
1414

15-
hugo.action("projects", () => {
15+
hugo.action("projects", async () => {
1616
// Projects file
1717
const projectsFile = hugo.cacheFile(untildify("~/.atom/projects.cson"));
1818
const configFile = hugo.cacheFile(untildify("~/.atom/config.cson"));
@@ -25,9 +25,6 @@ hugo.action("projects", () => {
2525
// Parse projects
2626
const p = Projects.parseCson(file);
2727

28-
// Rebuild icons when needed
29-
Icons.rebuild(p, { onlyMissing: true, theme: hugo.alfredTheme });
30-
3128
// Sort projects
3229
p.sort((a, b) => {
3330
const nameA = a.title.toLowerCase();
@@ -92,7 +89,7 @@ hugo.action("projects", () => {
9289
hugo.items = hugo.items.concat(projects);
9390

9491
// Check icons
95-
utils.checkIcons(hugo, projects);
92+
await utils.checkIcons(hugo, projects);
9693

9794
// Check if any projects found
9895
if (hugo.items.length === 0) {
@@ -102,7 +99,7 @@ hugo.action("projects", () => {
10299
}
103100

104101
// Output
105-
hugo.feedback();
102+
await hugo.feedback();
106103
});
107104

108105
hugo.run();

src/project.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import cson from "cson-parser";
2-
import { capitalCase } from "change-case";
2+
import {capitalCase} from "change-case";
33
import path from "path";
44
import glob from "glob";
5-
import { Item } from "alfred-hugo";
5+
import {Item} from "alfred-hugo";
66

7-
import { Project, Octicon } from "./types";
7+
import {Octicon, Project} from "./types";
88
import * as utils from "./utils";
9-
import { Icons } from "./icons";
9+
import {Icons} from "./icons";
1010

1111
export class Projects {
1212
/**
@@ -23,7 +23,7 @@ export class Projects {
2323
octicons = Icons.all();
2424
}
2525

26-
const item = {
26+
return {
2727
uid: Buffer.from(this.title(project) + this.subTitle(project), "utf8").toString("base64"),
2828
title: this.title(project),
2929
subtitle: this.subTitle(project),
@@ -60,8 +60,6 @@ export class Projects {
6060
},
6161
},
6262
};
63-
64-
return item;
6563
}
6664

6765
/**
@@ -75,7 +73,7 @@ export class Projects {
7573
for (const project of projects) {
7674
const p = this.parse(project, octicons);
7775

78-
if (p && p !== null) {
76+
if (p) {
7977
results.push(p);
8078
}
8179
}

src/utils.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,33 @@ export function checkEnvironmentChanges(hugo: Hugo): void {
2424
}
2525
}
2626

27-
export function checkIcons(hugo: Hugo, items: Item[]): Promise<void> {
27+
export async function checkIcons(hugo: Hugo, items: Item[]): Promise<void> {
2828
const themePath = hugo.alfredMeta.themeFile;
2929
const lastTheme = hugo.config.get("lastTheme");
3030

3131
try {
3232
fs.statSync(path.join(__dirname, "icons"));
3333
} catch (e) {
3434
hugo.config.set("lastTheme", hugo.alfredMeta.theme);
35-
Icons.rebuild(items, { theme: hugo.alfredTheme });
36-
return;
35+
return Icons.rebuild(items, { theme: hugo.alfredTheme });
3736
}
3837

3938
if (!lastTheme || lastTheme !== hugo.alfredMeta.theme) {
4039
hugo.config.set("lastTheme", hugo.alfredMeta.theme);
41-
Icons.rebuild(items, { theme: hugo.alfredTheme });
42-
return;
40+
return Icons.rebuild(items, { theme: hugo.alfredTheme });
4341
}
4442

4543
if (themePath) {
4644
const themeFile = hugo.cacheFile(themePath);
4745

48-
themeFile.on("change", () => {
49-
Icons.rebuild(items, { theme: hugo.alfredTheme });
46+
await themeFile.on("change", async () => {
47+
await Icons.rebuild(items, { theme: hugo.alfredTheme });
5048
});
5149

5250
themeFile.get();
5351
}
5452

55-
Icons.rebuild(items, { onlyMissing: true, theme: hugo.alfredTheme });
53+
return Icons.rebuild(items, { onlyMissing: true, theme: hugo.alfredTheme });
5654
}
5755

5856
export function fileExists(p: string): boolean {

0 commit comments

Comments
 (0)