Skip to content

Commit

Permalink
Use promisify.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Aug 1, 2017
1 parent 4f75e7f commit ea7e67e
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions tasks/ui_framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import postcss from 'postcss';
import postcssConfig from '../src/optimize/postcss.config';
import chokidar from 'chokidar';
import debounce from 'lodash/function/debounce';
import { promisify } from 'bluebird';

const platform = require('os').platform();
const isPlatformWindows = /^win/.test(platform);

const renderSass = promisify(sass.render);

module.exports = function (grunt) {
grunt.registerTask('uiFramework:build', function () {
const done = this.async();
Expand Down Expand Up @@ -82,26 +86,23 @@ module.exports = function (grunt) {
}

function uiFrameworkCompile() {
return new Promise(resolve => {
sass.render({
file: 'ui_framework/components/index.scss'
}, function (error, result) {
if (error) {
grunt.log.error(error);
}

postcss([postcssConfig])
.process(result.css, { from: 'ui_framework/components/index.scss', to: 'ui_framework/dist/ui_framework.css' })
.then(result => {
grunt.file.write('ui_framework/dist/ui_framework.css', result.css);

if (result.map) {
grunt.file.write('ui_framework/dist/ui_framework.css.map', result.map);
}

resolve();
});
});
const src = 'ui_framework/components/index.scss';
const dest = 'ui_framework/dist/ui_framework.css';

return renderSass({
file: src
}).then(result => {
postcss([postcssConfig])
.process(result.css, { from: src, to: dest })
.then(result => {
grunt.file.write(dest, result.css);

if (result.map) {
grunt.file.write(`${dest}.map`, result.map);
}
});
}).catch(error => {
grunt.log.error(error);
});
}

Expand Down

0 comments on commit ea7e67e

Please sign in to comment.