11import * as webpack from 'webpack';
2- import * as path from 'path ';
3- import * as rimraf from 'rimraf ';
2+ import { XI18nWebpackConfig } from '../models/webpack-xi18n-config ';
3+ import { getAppFromConfig } from '../utilities/app-utils ';
44
55const Task = require('../ember-cli/lib/models/task');
6+ const MemoryFS = require('memory-fs');
67
7- import {XI18nWebpackConfig} from '../models/webpack-xi18n-config';
8- import {getAppFromConfig} from '../utilities/app-utils';
98
109export const Extracti18nTask = Task.extend({
1110 run: function (runTaskOptions: any) {
12-
13- const project = this.project;
14-
1511 const appConfig = getAppFromConfig(runTaskOptions.app);
1612
17- const buildDir = '.tmp';
18- const genDir = runTaskOptions.outputPath || appConfig.root;
19-
2013 const config = new XI18nWebpackConfig({
21- genDir,
22- buildDir,
14+ genDir: runTaskOptions.outputPath || appConfig.root ,
15+ buildDir: '.tmp' ,
2316 i18nFormat: runTaskOptions.i18nFormat,
2417 locale: runTaskOptions.locale,
2518 outFile: runTaskOptions.outFile,
@@ -29,6 +22,7 @@ export const Extracti18nTask = Task.extend({
2922 }, appConfig).buildConfig();
3023
3124 const webpackCompiler = webpack(config);
25+ webpackCompiler.outputFileSystem = new MemoryFS();
3226
3327 return new Promise((resolve, reject) => {
3428 const callback: webpack.compiler.CompilerCallback = (err, stats) => {
@@ -45,15 +39,11 @@ export const Extracti18nTask = Task.extend({
4539
4640 webpackCompiler.run(callback);
4741 })
48- .then(() => {
49- // Deletes temporary build folder
50- rimraf.sync(path.resolve(project.root, buildDir));
51- })
52- .catch((err: Error) => {
53- if (err) {
54- this.ui.writeError('\nAn error occured during the i18n extraction:\n'
55- + ((err && err.stack) || err));
56- }
57- });
42+ .catch((err: Error) => {
43+ if (err) {
44+ this.ui.writeError('\nAn error occured during the i18n extraction:\n'
45+ + ((err && err.stack) || err));
46+ }
47+ });
5848 }
5949});
0 commit comments