Skip to content

Commit

Permalink
Transformed buildCodicon to JavaScript. Generated file contains licen…
Browse files Browse the repository at this point in the history
…se links
  • Loading branch information
kaisalmen committed Sep 12, 2022
1 parent 0c3d3f8 commit 243f10a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 90 deletions.
34 changes: 34 additions & 0 deletions packages/sprotty/build/src/buildCodicon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');

function transformCodicon() {
fs.readFile('../../node_modules/@vscode/codicons/dist/codicon.css', 'utf8', (err, cssData) => {
if (err) {
console.error(err);
return;
}

if (!fs.existsSync('./css/generated')) {
fs.mkdirSync('./css/generated');
}

fs.readFile('../../node_modules/@vscode/codicons/dist/codicon.ttf', 'base64', (errTtf, dataTtf) => {
if (errTtf) {
console.error(errTtf);
return;
}
const ttfData = `data:font/ttf;base64,${dataTtf}`;
let alteredCssData = cssData.replace('"./codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa"', ttfData);
const licRef = `/* See license here:
* https://github.com/microsoft/vscode-codicons/blob/main/LICENSE-CODE
* https://github.com/microsoft/vscode-codicons/blob/main/LICENSE
*/
@font-face {`
alteredCssData = alteredCssData.replace('@font-face {', licRef);

fs.writeFileSync('./css/generated/codicon.css', alteredCssData);
});
});
}

transformCodicon();
72 changes: 0 additions & 72 deletions packages/sprotty/build/src/buildCodicon.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/sprotty/build/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/sprotty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "shx rm -fr lib artifacts build/dist",
"build:generate": "shx rm -fr ./build/dist ./build/src/generated && shx mkdir -p ./build/src/generated && tsc -p ./build/tsconfig.json && node ./build/dist/buildCodicon.js",
"clean": "shx rm -fr lib artifacts css/generated",
"build:generate": "node ./build/src/buildCodicon.js",
"build": "yarn run build:generate && tsc -p ./tsconfig.json && yarn run lint",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*|test-helper.ts)\"",
Expand Down

0 comments on commit 243f10a

Please sign in to comment.