nixos-configs/modules/ags/config/js/utils.js
matt1432 eb9ba2a7a4
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(greetd): move ags conf into ags module
2024-02-05 22:46:43 -05:00

42 lines
1 KiB
JavaScript

const { execAsync, monitorFile } = Utils;
/** @param {string} host */
const watchAndCompileSass = (host) => {
const reloadCss = () => {
const scss = `${App.configDir}/scss/${host}.scss`;
const css = '/tmp/ags/style.css';
execAsync(`sassc ${scss} ${css}`).then(() => {
App.resetCss();
App.applyCss(css);
}).catch(print);
};
monitorFile(
`${App.configDir}/scss`,
reloadCss,
'directory',
);
reloadCss();
};
/** @param {string} host */
export const transpileTypeScript = async(host) => {
await execAsync([
'bun', 'build', `${App.configDir}/${host}.ts`,
'--outdir', '/tmp/ags',
'--external', 'resource:///*',
'--external', 'gi://*',
'--external', 'cairo',
'--external', '*/fzf.es.js',
]).catch(print);
if (host !== 'greeter') {
watchAndCompileSass(host);
}
// The file is going to be there after transpilation
// @ts-ignore
return await import(`file:///tmp/ags/${host}.js`);
};