deflopt: execute wine if platform not win32

This commit is contained in:
Christopher Monsanto
2020-09-15 08:38:18 -04:00
parent 837c09f0be
commit 4665871d5d
3 changed files with 8 additions and 9 deletions

View File

@@ -48,7 +48,7 @@ function compresspng(opts)
cmds += rep{"advpng -q ${opts} ${output}", opts=advpng, output=output}
end
if deflopt then
cmds += rep{"node ${root}/tools/deflopt --wine ${output}",
cmds += rep{"node ${root}/tools/deflopt ${output}",
root=ROOTDIR,
output=output}
end

View File

@@ -32,18 +32,18 @@ function parse(re : RegExp, output : string) {
const DEFLOPT_EXE = `${root}/vendor/DeflOpt.exe`;
export function deflopt({file, wine}: {file : string, wine: boolean}) {
export function deflopt(file : string) {
file = file.replace(/\//g, "\\");
let cmd, args;
if (wine) {
if (process.platform === 'win32') {
cmd = DEFLOPT_EXE;
args = [file];
} else {
cmd = "wine";
// DeflOpt doesn't like absolute paths, it thinks they are Windows-style
// command line switches.
args = [DEFLOPT_EXE, file];
} else {
cmd = DEFLOPT_EXE;
args = [file];
}
const output = cp.execFileSync(cmd, args, {encoding: 'utf8'});

View File

@@ -4,10 +4,9 @@ import program from 'commander';
import {deflopt} from './deflopt.js';
program
.option('--wine', 'Run executable with Wine')
.arguments('<file>')
.action((file : string, {wine} : {wine?: boolean}) => {
const {processed, rewritten} = deflopt({file, wine: !!wine});
.action((file : string) => {
const {processed, rewritten} = deflopt(file);
if (processed !== 1) {
console.error(`Didn't process any files.`);
process.exit(1);