mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
26 lines
784 B
JavaScript
26 lines
784 B
JavaScript
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
|
|
|
export default (manifestPath, repo) => {
|
|
const pcManifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
|
|
let manifest = {
|
|
main: 'index.js',
|
|
tags: ['port'],
|
|
|
|
name: pcManifest.name,
|
|
description: pcManifest.description,
|
|
|
|
version: pcManifest.version,
|
|
authors: [ pcManifest.author ]
|
|
};
|
|
|
|
rmSync(manifestPath);
|
|
mkdirSync(manifestPath);
|
|
|
|
const content = readFileSync(pcManifest.main || 'index.js', 'utf8');//.replace(/\\/g, '\\\\').replace(/`/g, '\\`');
|
|
|
|
const jsCode = content.replace(`module.exports = class`, `export default new class`);
|
|
|
|
writeFileSync(`${manifestPath}/goosemodModule.json`, JSON.stringify(manifest));
|
|
writeFileSync(`${manifestPath}/index.js`, jsCode);
|
|
};
|