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

[FEATURE] promisify sass call

parent c7275ba4
......@@ -3,6 +3,9 @@ const sass = require('node-sass');
const fs = require('fs');
const path = require('path');
const globby = require('globby');
const postcss = require('postcss');
const util = require('util');
const chalk = require('chalk');
/**
* The CSS task takes care of compiling Sass and running the CSS QA tasks
......@@ -38,21 +41,23 @@ module.exports = class Css extends Task {
* @param {String} _input The path to the input file
* @param {String} _output The path to the output file
*/
_compile(_input, _output) {
sass.render({
file: _input,
outputStyle: 'compressed'
}, (_error, _result) => {
if (!_error) {
fs.writeFile(_output, _result.css, _error => {
if (_error) {
return this.logError(_error);
}
console.log(`Compiled ${path.basename(_input)}`);
});
} else {
this.logError(_error);
async _compile(_input, _output) {
const render = util.promisify(sass.render);
let result;
try {
result = await render({
file: _input,
outputStyle: 'compressed'
});
} catch(_error) {
this._logger.error(_error);
}
fs.writeFile(_output, result.css, _error => {
if (_error) {
return this._logger.error(_error);
}
this._logger.success(`Compiled ${chalk.white(path.basename(_input))}`);
});
}
......
This diff is collapsed.
Markdown is supported
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