mirror of
https://github.com/grafana/grafana.git
synced 2025-09-22 11:43:24 +08:00
Regenerating variabless sas on theme edit v1
This commit is contained in:
35
scripts/cli/generateSassVariableFiles.ts
Normal file
35
scripts/cli/generateSassVariableFiles.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import fs from 'fs';
|
||||
import darkTheme from '@grafana/ui/src/themes/dark';
|
||||
import lightTheme from '@grafana/ui/src/themes/light';
|
||||
import { darkThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.dark.scss.tmpl';
|
||||
import { lightThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.light.scss.tmpl';
|
||||
|
||||
const darkThemeVariablesPath = __dirname + '/../../public/sass/_variables.dark.scss';
|
||||
const lightThemeVariablesPath = __dirname + '/../../public/sass/_variables.light.scss';
|
||||
|
||||
const writeVariablesFile = async (path: string, data: string) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writeFile(path, data, e => {
|
||||
if (e) {
|
||||
reject(e);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const generateSassVariableFiles = async () => {
|
||||
try {
|
||||
await Promise.all([
|
||||
writeVariablesFile(darkThemeVariablesPath, darkThemeVarsTemplate(darkTheme)),
|
||||
writeVariablesFile(lightThemeVariablesPath, lightThemeVarsTemplate(lightTheme)),
|
||||
]);
|
||||
console.log('\nSASS variable files generated');
|
||||
} catch (error) {
|
||||
console.error('\nWriting SASS variable files failed', error);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
generateSassVariableFiles();
|
Reference in New Issue
Block a user