UNPKG

1.81 kBJavaScriptView Raw
1"use strict";
2const webpack = require('webpack');
3const path = require('path');
4const rimraf = require('rimraf');
5const Task = require('../ember-cli/lib/models/task');
6const webpack_xi18n_config_1 = require('../models/webpack-xi18n-config');
7const config_1 = require('../models/config');
8exports.Extracti18nTask = Task.extend({
9 run: function (runTaskOptions) {
10 const project = this.project;
11 const appConfig = config_1.CliConfig.fromProject().config.apps[0];
12 const buildDir = '.tmp';
13 const genDir = runTaskOptions.outputPath || appConfig.root;
14 const config = new webpack_xi18n_config_1.XI18nWebpackConfig({
15 genDir,
16 buildDir,
17 i18nFormat: runTaskOptions.i18nFormat,
18 verbose: runTaskOptions.verbose,
19 progress: runTaskOptions.progress
20 }).config;
21 const webpackCompiler = webpack(config);
22 return new Promise((resolve, reject) => {
23 const callback = (err, stats) => {
24 if (err) {
25 return reject(err);
26 }
27 if (stats.hasErrors()) {
28 reject();
29 }
30 else {
31 resolve();
32 }
33 };
34 webpackCompiler.run(callback);
35 })
36 .then(() => {
37 // Deletes temporary build folder
38 rimraf.sync(path.resolve(project.root, buildDir));
39 })
40 .catch((err) => {
41 if (err) {
42 this.ui.writeError('\nAn error occured during the i18n extraction:\n'
43 + ((err && err.stack) || err));
44 }
45 throw err;
46 });
47 }
48});
49//# sourceMappingURL=/Users/hansl/Sources/angular-cli/packages/@angular/cli/tasks/extract-i18n.js.map
\No newline at end of file