Skip to content

Commit

Permalink
[Darkside] ✨ Now adds version-tokens to tokens css (#3466)
Browse files Browse the repository at this point in the history
* ✨ Now adds version-tokens to tokens css

* ♻️ Remove redundant exist-check
  • Loading branch information
KenAJoh authored Dec 19, 2024
1 parent 043277f commit 3025e4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions @navikt/core/tokens/config/version-tag.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { readFileSync, writeFileSync } from "fs";

const cssFilePath = "./dist/tokens.css";
const cssFilePaths = ["./dist/tokens.css", "./dist/darkside/tokens.css"];
const packageJsonPath = "./package.json";

const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
const version = packageJson.version;

let cssContent = readFileSync(cssFilePath, "utf8");
for (const path of cssFilePaths) {
let cssContent = readFileSync(path, "utf8");

if (!cssContent.includes("--a-version")) {
cssContent = cssContent.replace("{", `{\n --a-version: "${version}";`);
writeFileSync(cssFilePath, cssContent);
cssContent = cssContent.replace(
":root, :host {",
`:root, :host {\n --ax-version: "${version}";`,
);
writeFileSync(path, cssContent);
}
2 changes: 1 addition & 1 deletion @navikt/core/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"docs.json"
],
"scripts": {
"build": "tsx ./config/build.ts > /dev/null && tsx ./config/version-tag.ts && yarn build:darkside",
"build": "tsx ./config/build.ts > /dev/null && yarn build:darkside && tsx ./config/version-tag.ts",
"build:darkside": "tsx ./darkside && yarn build:figma-config && yarn build:plugin",
"build:figma-config": "tsx ./darkside/figma",
"build:plugin-dev": "esbuild darkside/figma/plugin/plugin.ts --target=es2016 --bundle --define:process.env.NODE_ENV=\\\"development\\\" --outfile='darkside/figma/plugin/plugin.js'",
Expand Down

0 comments on commit 3025e4e

Please sign in to comment.