try execFile
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user