From 4665871d5dd81b839c949d086deca0684c2e4444 Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Tue, 15 Sep 2020 08:38:18 -0400 Subject: [PATCH] deflopt: execute wine if platform not win32 --- Tuprules.lua | 2 +- tools/deflopt/deflopt.ts | 10 +++++----- tools/deflopt/index.ts | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Tuprules.lua b/Tuprules.lua index a12634b0..e610484f 100644 --- a/Tuprules.lua +++ b/Tuprules.lua @@ -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 diff --git a/tools/deflopt/deflopt.ts b/tools/deflopt/deflopt.ts index 724ca92e..f9dde8d3 100644 --- a/tools/deflopt/deflopt.ts +++ b/tools/deflopt/deflopt.ts @@ -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'}); diff --git a/tools/deflopt/index.ts b/tools/deflopt/index.ts index d37cb7e7..2b5c3f06 100644 --- a/tools/deflopt/index.ts +++ b/tools/deflopt/index.ts @@ -4,10 +4,9 @@ import program from 'commander'; import {deflopt} from './deflopt.js'; program - .option('--wine', 'Run executable with Wine') .arguments('') - .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);