From 3c2fec42f20c67f19062f5c31e16c2783ee8655d Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Tue, 22 Mar 2016 16:25:05 -0400 Subject: [PATCH] Only catch the `ENOENT` error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catch there before is meant to just continue if it comes across a file that doesn't exist (in which case the language will default to english). However, it was not specific enough – now, it only catches the error if the file doesn't exist, and throws anything else, preveting a build. --- bin/build-locales | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/build-locales b/bin/build-locales index 136ea385b..e5650eba5 100755 --- a/bin/build-locales +++ b/bin/build-locales @@ -54,10 +54,6 @@ if (!args.length) { process.stdout.write('A destination directory must be specified.'); process.exit(1); } -var verbose = false; -if (args.length > 1) { - verbose = (args[1] === '-v') ? true : false; -} var poUiDir = path.resolve(__dirname, '../node_modules/scratchr2_translations/ui'); var outputDir = path.resolve(__dirname, '../', args[0]); @@ -129,17 +125,23 @@ glob(poUiDir + '/*', function (err, files) { var translations = {}; try { + fs.accessSync(jsFile, fs.R_OK); var jsTranslations = po2icu.poFileToICUSync(lang, jsFile); translations = localeCompare.mergeNewTranslations(translations, jsTranslations, idsWithICU, md5WithIds); } catch (err) { - if (verbose) process.stdout.write(lang + ': ' + err + '\n'); + if (err.code !== 'ENOENT') { + throw err; + } } try { + fs.accessSync(pyFile, fs.R_OK); var pyTranslations = po2icu.poFileToICUSync(lang, pyFile); translations = localeCompare.mergeNewTranslations(translations, pyTranslations, idsWithICU, md5WithIds); } catch (err) { - if (verbose) process.stdout.write(lang + ': ' + err + '\n'); + if (err.code !== 'ENOENT') { + throw err; + } } // add new translations to locale object