UNPKG

ngc-webpack

Version:

A wrapper for the @ngtools/webpack with hooks into the compilation process

66 lines 2.65 kB
"use strict"; var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var ts = require("typescript"); var compiler_cli_1 = require("@angular/compiler-cli"); function readNgcCommandLineAndConfiguration(args, parsedArgs) { var options = {}; parsedArgs = parsedArgs || require('minimist')(args); if (parsedArgs.i18nFile) options.i18nInFile = parsedArgs.i18nFile; if (parsedArgs.i18nFormat) options.i18nInFormat = parsedArgs.i18nFormat; if (parsedArgs.locale) options.i18nInLocale = parsedArgs.locale; var mt = parsedArgs.missingTranslation; if (mt === 'error' || mt === 'warning' || mt === 'ignore') { options.i18nInMissingTranslations = mt; } var config = readCommandLineAndConfiguration(args, options, ['i18nFile', 'i18nFormat', 'locale', 'missingTranslation', 'watch']); var watch = parsedArgs.w || parsedArgs.watch; return __assign({}, config, { watch: !!watch }); } exports.readNgcCommandLineAndConfiguration = readNgcCommandLineAndConfiguration; function readCommandLineAndConfiguration(args, existingOptions, ngCmdLineOptions) { if (existingOptions === void 0) { existingOptions = {}; } if (ngCmdLineOptions === void 0) { ngCmdLineOptions = []; } var cmdConfig = ts.parseCommandLine(args); var project = cmdConfig.options.project || '.'; var cmdErrors = cmdConfig.errors.filter(function (e) { if (typeof e.messageText === 'string') { var msg_1 = e.messageText; return !ngCmdLineOptions.some(function (o) { return msg_1.indexOf(o) >= 0; }); } return true; }); if (cmdErrors.length) { return { project: project, rootNames: [], options: cmdConfig.options, errors: cmdErrors, emitFlags: compiler_cli_1.EmitFlags.Default }; } var config = compiler_cli_1.readConfiguration(project, cmdConfig.options); var options = __assign({}, config.options, existingOptions); if (options.locale) { options.i18nInLocale = options.locale; } return { project: project, rootNames: config.rootNames, options: options, errors: config.errors, emitFlags: config.emitFlags }; } exports.readCommandLineAndConfiguration = readCommandLineAndConfiguration; //# sourceMappingURL=config.js.map