コード例 #1
0
ファイル: index.js プロジェクト: Angeldude/bulma-website
function writeResult (name, content, fn) {
  var funcs = [
    async.apply(writeFile, name, content.css)
  ];
  if (content.map && name) {
    funcs.push(async.apply(writeFile, name + '.map', content.map.toString()));
  }
  async.parallel(funcs, fn);
}
コード例 #2
0
ファイル: index.js プロジェクト: Angeldude/bulma-website
function processCSS(processor, input, output, fn) {
  function doProcess(css, fn) {
    function onResult(result) {
      if (typeof result.warnings === 'function') {
        result.warnings().forEach(function(w) { console.warn(w.toString()); });
      }
      fn(null, result);
    }

    var options = {
      from: input,
      to: output
    };

    Object.keys(customSyntaxOptions).forEach(function(opt) {
      options[opt] = customSyntaxOptions[opt];
    });

    if (typeof mapOptions !== 'undefined') {
      options.map = mapOptions;
    }

    var result = processor.process(css, options);

    if (typeof result.then === 'function') {
      result.then(onResult).catch(fn);
    } else {
      process.nextTick(onResult.bind(null, result));
    }
  }

  async.waterfall([
    async.apply(readFile, input),
    doProcess,
    async.apply(writeResult, output)
  ], fn);
}