fs.readdir(input, function(err, files) { if(err) { console.error(err); callback(); return; } // * LESS files: end in .less and not directories var less = files.filter(function(f) { return /\.less$/.test(f) && !fs.statSync(path.join(input, f)).isDirectory(); }); // * only callback after all files are processed var counter = 0, cbjoin = function() { if(++counter == less.length) { callback(); } }; less.forEach(function(f) { var inf = path.join(input, f); var outf = path.join(output || input, f).replace(/\.less$/, ".css"); resolve(inf, outf, options, cbjoin); }); // * continue if no less files found. if(less.length == 0) { console.warn("No LESS files found in directory: " + input); callback(); } });
function preprocess() { less.forEach(function(file) { var plugin = file.pkg.parent.plugin; var id = file.pkg.id.replace(/^[^!]+!/, ""); code.push( "/* @file " + id + " */\nß{" + expandVariables(file.code, Object.create(null), plugin) + "}" ); }); code = code.join("\n") + expandVariables(libs.map(function(l) { return l.code ? "/* @file " + l.id + " */\n" + l.code : ""; }).join("\n"), Object.create(null)); }