Skip to content

Commit

Permalink
Richie-js icon added to vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
darsan-in committed Nov 15, 2024
1 parent f7c2bd0 commit 3c25002
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

![Richi JS logo](./logo.png)
![Richi JS logo](./logo/rjs-icon.svg)

# Richie JS - Powerful SEO Tool for Generating Rich Results

Expand Down
42 changes: 39 additions & 3 deletions bin/schemaWriter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { copyFile, readFile, writeFile } from "fs/promises";
import { existsSync, mkdirSync } from "node:fs";
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
import { basename, dirname, join } from "path";

type isenseModes = "user" | "ws";
Expand Down Expand Up @@ -59,6 +59,11 @@ function appendSettings(
newConfigs["json.schemas"] = [schemaConfigSnippet];
}

/* Associate icon to configuration file. */
copyRichieJSIcon();
newConfigs = { ...newConfigs, ...iconAssociationObject };
/* */

return new Promise((resolve, reject) => {
writeFile(configPath, JSON.stringify(newConfigs, null, 3))
.then(() => {
Expand All @@ -80,7 +85,7 @@ function createSettings(
};

if (mkParentFolder) {
mkdirSync(dirname(configPath));
mkdirSync(dirname(configPath), { recursive: true });
}

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -165,7 +170,7 @@ function writeSettings(
reject(err);
});
} else {
reject("Other error: " + err.message);
reject("Other error: " + err);
}
}
} else {
Expand Down Expand Up @@ -210,3 +215,34 @@ export function isense(): Promise<void> {
});
}
}

const iconAssociationObject = {
"material-icon-theme.files.associations": {
".richiejs": "../../icons/rjs-icon",
},
};

async function copyRichieJSIcon() {
const userHome: string = (
process.platform === "win32" ?
join(process.env.HOMEDRIVE ?? "", process.env.HOMEPATH ?? "")
: process.env.HOME) as string;

const destPath = join(
userHome,
".vscode",
"extensions",
"icons",
"rjs-icon.svg",
);

const source = join(__dirname, "..", "..", "logo", "rjs-icon.svg");

try {
mkdirSync(dirname(destPath), { recursive: true });
copyFileSync(source, destPath);
} catch (err) {
console.log("Error copying icon: ", err);
process.exit(1);
}
}
Binary file removed logo.png
Binary file not shown.
1 change: 1 addition & 0 deletions logo/rjs-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"main": "./dist/richie.js",
"files": [
"dist",
"intellisense"
"intellisense",
"logo"
],
"directories": {
"lib": "./dist/lib"
Expand Down

0 comments on commit 3c25002

Please sign in to comment.