Commit 3c2fec42 authored by Matthew Taylor's avatar Matthew Taylor

Only catch the `ENOENT` error

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.
parent faf35495
...@@ -54,10 +54,6 @@ if (!args.length) { ...@@ -54,10 +54,6 @@ if (!args.length) {
process.stdout.write('A destination directory must be specified.'); process.stdout.write('A destination directory must be specified.');
process.exit(1); 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 poUiDir = path.resolve(__dirname, '../node_modules/scratchr2_translations/ui');
var outputDir = path.resolve(__dirname, '../', args[0]); var outputDir = path.resolve(__dirname, '../', args[0]);
...@@ -129,17 +125,23 @@ glob(poUiDir + '/*', function (err, files) { ...@@ -129,17 +125,23 @@ glob(poUiDir + '/*', function (err, files) {
var translations = {}; var translations = {};
try { try {
fs.accessSync(jsFile, fs.R_OK);
var jsTranslations = po2icu.poFileToICUSync(lang, jsFile); var jsTranslations = po2icu.poFileToICUSync(lang, jsFile);
translations = localeCompare.mergeNewTranslations(translations, jsTranslations, idsWithICU, md5WithIds); translations = localeCompare.mergeNewTranslations(translations, jsTranslations, idsWithICU, md5WithIds);
} catch (err) { } catch (err) {
if (verbose) process.stdout.write(lang + ': ' + err + '\n'); if (err.code !== 'ENOENT') {
throw err;
}
} }
try { try {
fs.accessSync(pyFile, fs.R_OK);
var pyTranslations = po2icu.poFileToICUSync(lang, pyFile); var pyTranslations = po2icu.poFileToICUSync(lang, pyFile);
translations = localeCompare.mergeNewTranslations(translations, pyTranslations, idsWithICU, md5WithIds); translations = localeCompare.mergeNewTranslations(translations, pyTranslations, idsWithICU, md5WithIds);
} catch (err) { } catch (err) {
if (verbose) process.stdout.write(lang + ': ' + err + '\n'); if (err.code !== 'ENOENT') {
throw err;
}
} }
// add new translations to locale object // add new translations to locale object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment