Files
picobook/src/server/util/pico8.ts
T

27 lines
716 B
TypeScript
Raw Normal View History

2024-03-27 19:17:12 -07:00
import fs from "fs";
import path from "path";
import {fileURLToPath} from 'url';
import {execFile} from "child_process";
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const picoDirPath = path.resolve(__dirname, "..", "..", "..", "pico8");
const picoBinPath = path.resolve(picoDirPath, "pico8");
const execPico = (args: string[]) => {
return new Promise((resolve, reject) => {
const options = {};
execFile(picoBinPath, args, options, (error, stdout, stderr) => {
if (error) {
reject({error, stderr});
} else {
resolve({stdout});
}
})
});
}
export const pico8 = {
async export(fileIn: string, fileOut: string) {
return await execPico([fileIn, "-export", fileOut]);
}
}