Skip to content

Instantly share code, notes, and snippets.

@wilsonpage
Created January 17, 2013 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsonpage/4556128 to your computer and use it in GitHub Desktop.
Save wilsonpage/4556128 to your computer and use it in GitHub Desktop.
The first fails to add the new file to the styles file list. The second one succeeds. I believe it to be related to the component.json being retrieved more than once.
var Builder = require('component-builder');
var path = require('path');
var fs = require('fs');
var async = require('async');
var builder = new Builder(__dirname + '/../client/item-view');
builder.use(compileSass);
builder.build(function(err, res){
if (err) throw err;
console.log(res);
});
function compileSass(builder) {
builder.hook('before styles', function(pkg, callback){
var styles = pkg.conf.sass;
if (!styles) return callback();
async.forEach(styles, function(file, callback) {
var ext = path.extname(file);
if ('.scss' != ext);
setTimeout(function() {
file = path.basename(file, '.scss') + '.css';
pkg.addFile('styles', file, '.my-styles {}');
callback();
}, 50);
}, function() {
callback();
});
});
}
var Builder = require('component-builder');
var path = require('path');
var fs = require('fs');
var async = require('async');
var builder = new Builder(__dirname + '/../client/item-view');
builder.use(compileSass);
builder.build(function(err, res){
if (err) throw err;
console.log(res);
});
function compileSass(builder) {
builder.hook('before styles', function(pkg, callback){
var styles = pkg.conf.sass;
if (!styles) return callback();
async.forEach(styles, function(file, callback) {
var ext = path.extname(file);
if ('.scss' != ext);
//setTimeout(function() {
file = path.basename(file, '.scss') + '.css';
pkg.addFile('styles', file, '.my-styles {}');
callback();
//}, 50);
}, function() {
callback();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment