Commit dac1ddd3 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[BUGFIX] fix failing tasks when no abovethefold css is present + improve

error logging
parent 0e794447
...@@ -56,6 +56,21 @@ class Settings { ...@@ -56,6 +56,21 @@ class Settings {
extension = _extensionName; extension = _extensionName;
} }
/**
* Returns the name of the current extension
*
* @return {*}
* @constructor
*/
get Extension() {
return extension;
}
/**
* Sets the flag that indicates if the current execution involves the watch task
*
* @param _value
*/
setWatcherActive(_value) { setWatcherActive(_value) {
watcherActive = _value; watcherActive = _value;
} }
......
...@@ -19,6 +19,7 @@ module.exports = class task { ...@@ -19,6 +19,7 @@ module.exports = class task {
this._config = settings.config; this._config = settings.config;
this._path = this._settings.getPath(); this._path = this._settings.getPath();
this._logger = require('./logger'); this._logger = require('./logger');
this.extensionName = settings.Extension;
if (argv.prod || argv.production) { if (argv.prod || argv.production) {
this._config.cssPipeline = this._config.css.pipeline.prod; this._config.cssPipeline = this._config.css.pipeline.prod;
this._config.jsPipeline = this._config.js.pipeline.prod; this._config.jsPipeline = this._config.js.pipeline.prod;
...@@ -63,7 +64,7 @@ module.exports = class task { ...@@ -63,7 +64,7 @@ module.exports = class task {
} }
_handleError(_errorMessage) { _handleError(_errorMessage) {
this._logger.error(chalk.bgRed(chalk.whiteBright(` Task ${this.constructor.name} failed: `))); this._logger.error(chalk.bgRed(chalk.whiteBright(` Task ${chalk.black(this.constructor.name)} for extension ${chalk.black(this.extensionName)} failed: `)));
this._logger.error(_errorMessage); this._logger.error(_errorMessage);
if (!settings.watcherActive) { if (!settings.watcherActive) {
process.exit(1); process.exit(1);
......
...@@ -299,7 +299,12 @@ module.exports = class Css extends Task { ...@@ -299,7 +299,12 @@ module.exports = class Css extends Task {
await this._writeFile(path.join(distDirectory, filename), html); await this._writeFile(path.join(distDirectory, filename), html);
} catch (_error) { } catch (_error) {
this._handleError(_error.stack); if (_error.message.indexOf('ENOENT: no such file') >= 0) {
this._logger.info(`Could not find abovethefold assets for ${this.extensionName}. Skip task.`);
resolve();
} else {
this._handleError(_error.message);
}
} }
this._logger.success(`Written ${chalk.white(path.basename(filename))}`); this._logger.success(`Written ${chalk.white(path.basename(filename))}`);
resolve(); resolve();
......
Supports Markdown
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