Comparing version 0.0.12 to 0.0.13
127
lib/CLI.js
@@ -1,2 +0,9 @@ | ||
var colors = require('colors'); | ||
var colors = require('colors'), | ||
glob = require("glob"), | ||
fs = require("fs"), | ||
pathToWatch = '', | ||
pathFiles = [], | ||
watcher, | ||
absurd, | ||
argv; | ||
@@ -18,3 +25,42 @@ var compile = function(absurd, source, output) { | ||
module.exports = function(argv, absurd) { | ||
var checkForNewFiles = function() { | ||
glob(pathToWatch, {}, function (err, files) { | ||
if(err) { | ||
console.log(("> glob error").red, err); | ||
} else { | ||
// comparing | ||
if(pathFiles && pathFiles.length > 0) { | ||
for(var i=0; i<files.length; i++) { | ||
var fNew = files[i]; | ||
var isItThere = false; | ||
for(var j=0; j<pathFiles.length; j++) { | ||
var fOld = pathFiles[j]; | ||
if(fNew == fOld) { | ||
isItThere = true; | ||
} | ||
} | ||
if(!isItThere) { | ||
watcher.add([fNew], function(){}); | ||
eventFired("added", fNew); | ||
} | ||
} | ||
} | ||
pathFiles = files; | ||
} | ||
setTimeout(checkForNewFiles, 500); | ||
}); | ||
} | ||
var eventFired = function(event, filepath) { | ||
fs.stat(filepath, function(err, stats) { | ||
if(stats && stats.isFile()) { | ||
console.log(("> " + event + ": " + filepath).yellow); | ||
compile(absurd, argv.s, argv.o); | ||
} | ||
}); | ||
} | ||
module.exports = function(ar, ab) { | ||
argv = ar; | ||
absurd = ab; | ||
// if there is source provided | ||
@@ -25,65 +71,20 @@ if(argv.s) { | ||
if(argv.w) { | ||
// var watchr = require('watchr'); | ||
// var paths = argv.w.split(","); | ||
// watchr.watch({ | ||
// paths: paths, | ||
// listeners: { | ||
// log: function(logLevel){ | ||
// // console.log('a log message occured:', arguments); | ||
// }, | ||
// error: function(err){ | ||
// console.log('> an error occured:'.red, err); | ||
// }, | ||
// watching: function(err, watcherInstance, isWatching){ | ||
// if (err) { | ||
// console.log(("> watching the path " + watcherInstance.path + " failed with error").red, err); | ||
// } else { | ||
// // console.log("watching the path " + watcherInstance.path + " completed"); | ||
// } | ||
// }, | ||
// change: function(changeType,filePath,fileCurrentStat,filePreviousStat){ | ||
// console.log(("> " + arguments[0] + ": " + arguments[1]).yellow); | ||
// compile(absurd, argv.s, argv.o); | ||
// } | ||
// }, | ||
// next: function(err, watchers) { | ||
// if (err) { | ||
// return console.log("watching everything failed with error", err); | ||
// } else { | ||
// for(var i=0; w=watchers[i]; i++) { | ||
// console.log(("> watching " + w.config.path).magenta); | ||
// } | ||
// } | ||
// // Close watchers after 60 seconds | ||
// // setTimeout(function(){ | ||
// // var i; | ||
// // console.log('Stop watching our paths'); | ||
// // for ( i=0; i<watchers.length; i++ ) { | ||
// // watchers[i].close(); | ||
// // } | ||
// // },60*1000); | ||
// } | ||
// }); | ||
pathToWatch = process.cwd() + "/" + argv.w + "/**/*.js"; | ||
var startWatcher = function() { | ||
var Gaze = require('gaze').Gaze; | ||
new Gaze([pathToWatch], {}, function(err) { | ||
if(err) console.log(('> ' + err).read); | ||
watcher = this; | ||
watcher.on('all', function(event, filepath) { | ||
eventFired(event, filepath); | ||
}); | ||
}) | ||
} | ||
var watch = require('watch') | ||
watch.createMonitor(argv.w, { | ||
ignoreDotFiles: true | ||
}, function (monitor) { | ||
monitor.files['/home/mikeal/.zshrc'] // Stat object for my zshrc. | ||
monitor.on("created", function (f, stat) { | ||
console.log(("> new file created: " + f).yellow); | ||
compile(absurd, argv.s, argv.o); | ||
}); | ||
monitor.on("changed", function (f, curr, prev) { | ||
console.log(("> file changed: " + f).yellow); | ||
compile(absurd, argv.s, argv.o); | ||
}); | ||
monitor.on("removed", function (f, stat) { | ||
console.log(("> file deleted: " + f).yellow); | ||
compile(absurd, argv.s, argv.o); | ||
}); | ||
}) | ||
console.log(("> watching: \n> " + pathToWatch).magenta); | ||
startWatcher(); | ||
checkForNewFiles(); | ||
console.log(("> watching " + argv.w).magenta); | ||
} | ||
@@ -90,0 +91,0 @@ } |
{ | ||
"name": "absurd", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"homepage": "https://github.com/krasimir/absurd", | ||
@@ -12,3 +12,4 @@ "description": "CSS preprocessor", | ||
"colors": "0.6.2", | ||
"watch": "0.8.0" | ||
"gaze": "0.4.1", | ||
"glob": "3.2.6" | ||
}, | ||
@@ -15,0 +16,0 @@ "keywords": [ |
@@ -11,3 +11,3 @@ module.exports = function(A) { | ||
p: { | ||
'line-height': '30px' | ||
'line-height': '32px' | ||
} | ||
@@ -18,6 +18,7 @@ } | ||
'header .logo': { | ||
'font-size': '18px' | ||
'font-size': '23px', | ||
'padding-top': '13.22px' | ||
} | ||
}); | ||
A.import(__dirname + "/config/others.js"); | ||
// A.import(__dirname + "/config/jjj.js"); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30
588
21134
4
7
+ Addedgaze@0.4.1
+ Addedglob@3.2.6
+ Addedgaze@0.4.1(transitive)
+ Addedglob@3.1.213.2.6(transitive)
+ Addedglobule@0.1.0(transitive)
+ Addedgraceful-fs@1.2.3(transitive)
+ Addedinherits@1.0.22.0.4(transitive)
+ Addedlodash@1.0.2(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.14(transitive)
+ Addedsigmund@1.0.1(transitive)
- Removedwatch@0.8.0
- Removedwatch@0.8.0(transitive)