Last active
January 24, 2017 18:04
-
-
Save rbtsolis/9e6ae5bc0588e777e7956fce1e0b4569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
path = require('path'), | |
child_process = require('child_process'); | |
function watchStyles(sourcefile, destinationfolder) { | |
var Stylus = child_process.spawn('stylus', ['-c','-u', 'nib','-w', sourcefile, '--out', destinationfolder]); | |
Stylus.stdout.pipe(process.stdout); // notifications: watching, compiled, generated. | |
Stylus.stderr.pipe(process.stdout); // warnings: ParseError. | |
Stylus.on('error', function(err) { | |
console.log("Stylus process("+Stylus.pid+") error: "+err); | |
console.log(err); | |
}); | |
// Report unclean exit. | |
Stylus.on('close', function (code) { | |
if (code !== 0) { | |
console.log("Stylus process("+Stylus.pid+") exited with code " + code); | |
} | |
}); | |
} | |
function getDirectories(srcpath) { | |
return fs.readdirSync(srcpath).filter(function(file) { | |
return fs.statSync(path.join(srcpath, file)).isDirectory(); | |
}); | |
} | |
var directories = getDirectories(__dirname); | |
function fromDir(directory,startPath,filter){ | |
//console.log('Starting from dir '+startPath+'/'); | |
if (!fs.existsSync(startPath)){ | |
console.log("no dir ",startPath); | |
return; | |
} | |
var files=fs.readdirSync(startPath); | |
for(var i=0;i<files.length;i++){ | |
var filename=path.join(startPath,files[i]); | |
var stat = fs.lstatSync(filename); | |
if (stat.isDirectory()){ | |
fromDir(filename,filter); //recurse | |
} | |
else if (filename.indexOf(filter)>=0) { | |
watchStyles(filename,`${directory}/css/`) | |
//console.log('-- found: ',filename); | |
}; | |
}; | |
}; | |
for(let directory of directories) | |
{ | |
fromDir(`${__dirname}/${directory}/`,`${__dirname}/${directory}/stylus/`,'.styl'); | |
} | |
.some{display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:box;display:flex;-webkit-box-lines:multiple;-moz-box-lines:multiple;-o-box-lines:multiple;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment