mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
44 lines
989 B
JavaScript
44 lines
989 B
JavaScript
|
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
||
|
|
||
|
export default (manifestPath, repo) => {
|
||
|
const pcManifest = JSON.parse(readFileSync(manifestPath));
|
||
|
|
||
|
const manifest = {
|
||
|
main: 'index.js',
|
||
|
tags: ['theme', 'port'],
|
||
|
|
||
|
name: pcManifest.name,
|
||
|
description: pcManifest.description,
|
||
|
|
||
|
version: pcManifest.version,
|
||
|
authors: [ pcManifest.author ]
|
||
|
};
|
||
|
|
||
|
rmSync(themePath);
|
||
|
mkdirSync(themePath);
|
||
|
|
||
|
const jsCode = `// Generated by MS2Builder - pcTheme preprocessor / porter
|
||
|
let style;
|
||
|
|
||
|
export default {
|
||
|
goosemodHandlers: {
|
||
|
onImport: async () => {
|
||
|
style = document.createElement("style");
|
||
|
document.head.appendChild(style);
|
||
|
style.appendChild(
|
||
|
document.createTextNode(
|
||
|
\`${content}\`
|
||
|
)
|
||
|
);
|
||
|
},
|
||
|
|
||
|
onRemove: async () => {
|
||
|
style.remove();
|
||
|
},
|
||
|
}
|
||
|
};`;
|
||
|
|
||
|
writeFileSync(`${themePath}/goosemodModule.json`, JSON.stringify(manifest));
|
||
|
writeFileSync(`${themePath}/index.js`, jsCode);
|
||
|
};
|