From a3daf85debc98841f676879b048196650be11310 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 19 Jul 2016 21:26:50 +0100 Subject: [PATCH] Let potomo detect a Cygwin gettext install This is useful on AppVeyor, which has Cygwin with the gettext-devel package installed by default. --- scripts/potomo.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/potomo.js b/scripts/potomo.js index f7fbffa5..f5a34c7f 100644 --- a/scripts/potomo.js +++ b/scripts/potomo.js @@ -3,9 +3,25 @@ const childProcess = require('child_process'); const fs = require('fs'); const path = require('path'); +const helpers = require('./helpers'); -/* This isn't portable but it doesn't (yet?) need to be. */ -const msgfmtPath = path.join('C:\\', 'Program Files (x86)', 'Poedit', 'GettextTools', 'bin', 'msgfmt.exe'); +function getMsgfmtPath() { + const paths = [ + path.join('C:\\', 'Program Files (x86)', 'Poedit', 'GettextTools', 'bin', 'msgfmt.exe'), + path.join('C:\\', 'cygwin', 'bin', 'msgfmt.exe'), + ]; + + for (let i = 0; i < paths.length; ++i) { + if (helpers.fileExists(paths[i])) { + return paths[i]; + } + } + + throw new Error('No msgfmt.exe found!'); +} + +/* This isn't portable to Linux but it doesn't (yet?) need to be. */ +const msgfmtPath = getMsgfmtPath(); let rootPath = '.'; if (process.argv.length > 2) {