diff options
| author | Tobias Bosch | 2014-02-06 17:49:14 -0800 | 
|---|---|---|
| committer | Tobias Bosch | 2014-02-06 17:53:37 -0800 | 
| commit | fcf4393680191584677872c686f26bfff01e4f37 (patch) | |
| tree | 6b1f5b4915efb01d5b5703ff00b75a74c4c9b1fc /i18n/src/closureSlurper.js | |
| parent | 16301bed2838276b1d5f315bde621edb32f82c6c (diff) | |
| download | angular.js-fcf4393680191584677872c686f26bfff01e4f37.tar.bz2 | |
chore(build): Update closure i18n integration
Use git repo as source and use q-io instead of q-fs
Diffstat (limited to 'i18n/src/closureSlurper.js')
| -rwxr-xr-x | i18n/src/closureSlurper.js | 40 | 
1 files changed, 28 insertions, 12 deletions
| diff --git a/i18n/src/closureSlurper.js b/i18n/src/closureSlurper.js index 9f236cf2..02a1d9ef 100755 --- a/i18n/src/closureSlurper.js +++ b/i18n/src/closureSlurper.js @@ -2,7 +2,7 @@  'use strict';  var Q  = require('q'), -    qfs  = require('q-fs'), +    qfs  = require('q-io/fs'),      converter = require('./converter.js'),      util = require('./util.js'),      closureI18nExtractor = require('./closureI18nExtractor.js'), @@ -47,24 +47,40 @@ function extractPlurals() {  function writeLocaleFiles() {    console.log('Final stage: Writing angular locale files to directory: %j', NG_LOCALE_DIR); -  var writePromises = []; +  var result = Q.defer();    var localeIds = Object.keys(localeInfo);    var num_files = 0; -  localeIds.forEach(function(localeID) { + +  console.log('Generated %j locale files.', localeIds.length); +  loop(); +  return result.promise; + +  // Need to use a loop and not write the files in parallel, +  // as otherwise we will get the error EMFILE, which means +  // we have too many open files. +  function loop() { +    var nextPromise; +    if (localeIds.length) { +      nextPromise = process(localeIds.pop()) || Q.when(); +      nextPromise.then(loop, result.reject); +    } else { +      result.resolve(num_files); +    } +  } + +  function process(localeID) {      var content = closureI18nExtractor.outputLocale(localeInfo, localeID);      if (!content) return;      var correctedLocaleId = closureI18nExtractor.correctedLocaleId(localeID);      var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js' -    writePromises.push( -      qfs.write(filename, content) -      .then(function () { -        console.log('Wrote ' + filename); -        ++num_files; -        }));      console.log('Writing ' + filename); -  }); -  console.log('Generated %j locale files.', localeIds.length); -  return Q.all(writePromises).then(function() { return num_files }); +    return qfs.write(filename, content) +        .then(function () { +          console.log('Wrote ' + filename); +          ++num_files; +        }); +  } +  }  /** | 
