Skip to content

Commit

Permalink
feat(design): add logging to CSS generation (#2111)
Browse files Browse the repository at this point in the history
## Proposed change

Add logging to Design Token based CSS generation.
  • Loading branch information
kpanot authored Aug 29, 2024
2 parents cf9558a + d4f19a3 commit 4356060
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/@o3r/design/builders/generate-css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { DesignTokenGroupTemplate, DesignTokenRendererOptions, DesignTokenV
import { resolve } from 'node:path';
import { sync } from 'globby';
import { EOL } from 'node:os';
import { readFile } from 'node:fs/promises';
import { readFile, writeFile } from 'node:fs/promises';

/**
* Generate CSS from Design Token files
Expand All @@ -42,7 +42,14 @@ export default createBuilder<GenerateCssSchematicsSchema>(async (options, contex
tokenVariableNameRenderer: (v) => (options?.prefixPrivate || '') + tokenVariableNameSassRenderer(v),
logger
});
const writeFileWithLogger: typeof writeFile = async (file, ...args) => {
const res = await writeFile(file, ...args);
// eslint-disable-next-line @typescript-eslint/no-base-to-string
logger.info(`Updated ${file.toString()} with Design Token content.`);
return res;
};
const renderDesignTokenOptionsCss: DesignTokenRendererOptions = {
writeFile: writeFileWithLogger,
determineFileToUpdate,
tokenDefinitionRenderer: getCssTokenDefinitionRenderer({
tokenVariableNameRenderer,
Expand All @@ -57,6 +64,7 @@ export default createBuilder<GenerateCssSchematicsSchema>(async (options, contex
};

const renderDesignTokenOptionsSass: DesignTokenRendererOptions = {
writeFile: writeFileWithLogger,
determineFileToUpdate,
tokenDefinitionRenderer: getSassTokenDefinitionRenderer({
tokenVariableNameRenderer: (v) => (options?.prefix || '') + tokenVariableNameSassRenderer(v),
Expand Down

0 comments on commit 4356060

Please sign in to comment.