Comparing version 0.2.24 to 0.3.26
@@ -5,4 +5,5 @@ #!/usr/bin/env node | ||
var io = require('faye'); | ||
var portscanner = require('portscanner'); | ||
var argv = require('optimist').argv; | ||
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); | ||
require(lib + '/main.js'); |
@@ -6,9 +6,11 @@ //Ver: https://github.com/bevry/watchr | ||
var megaServerTrans = null; | ||
var megaServerIns = null; | ||
var connectedIns = false; | ||
var lastPort = null; | ||
var Faye = require('faye'); | ||
var portscanner = require('portscanner'); | ||
var fs = require('fs'); | ||
var watch = require('./watch-k'); | ||
var fs = require('fs'); | ||
var serverDefaultChannel = "root"; | ||
var serverPort = 35729; | ||
var pathChceker = require('fs'); | ||
@@ -19,22 +21,46 @@ | ||
exports.watchers = function(path2watch, ignore, only, watch_interval, inject, name){ | ||
console.log("\watchers v0.2.24"); | ||
console.log("\nwatchers v0.3.26"); | ||
addMegaServer({port:serverPort}); | ||
lastPort = serverPort; | ||
lastPort++; | ||
var watcherOptions = | ||
{ | ||
path2watch:path2watch, | ||
ignore:ignore, | ||
only:only, | ||
port:lastPort, | ||
watch_interval:watch_interval, | ||
inject:inject, | ||
name:name | ||
}; | ||
if (path2watch!==null){ | ||
setTimeout(function() { | ||
addServerWatcher ({ | ||
path2watch:path2watch, | ||
ignore:ignore, | ||
only:only, | ||
port:lastPort, | ||
watch_interval:watch_interval, | ||
inject:inject, | ||
name:name | ||
}); | ||
}, 50); | ||
} | ||
//VARS OPT | ||
portscanner.findAPortNotInUse(serverPort, serverPort, 'localhost', function(error, portAvaiable) { | ||
if (portAvaiable == serverPort){ | ||
addMegaServer({port:serverPort}); | ||
lastPort = serverPort + 1; | ||
if (path2watch!==null){ | ||
setTimeout(function() { | ||
addServerWatcher (watcherOptions); | ||
}, 50); | ||
} | ||
}else{ | ||
/*MegaServer ya creado*/ | ||
if (path2watch!==null){ | ||
megaServerIns = new Faye.Client("http://localhost" + ':'+'35729'+'/' , {}); | ||
megaServerIns.subscribe('/'+ serverDefaultChannel, function(message) { | ||
if (message.init) { | ||
if (!connectedIns){ | ||
connectedIns = true; | ||
console.log('\n[MegaServerConnected] ___________________'); | ||
megaServerIns.publish('/'+serverDefaultChannel+"toServer", {action:'createWatchers', options:watcherOptions}); | ||
} | ||
} | ||
}); | ||
megaServerIns.subscribe('/'+ serverDefaultChannel +"/serverCreatedOk", function(message) { | ||
console.log('\n[Watcher ' + watcherOptions.name + ' , created sucessfully in other instance, bye!]'); | ||
process.exit(code=0); | ||
}); | ||
} | ||
} | ||
}); | ||
}; | ||
@@ -48,2 +74,4 @@ | ||
if (megaServer !== null) return; | ||
//VARS OPT | ||
@@ -64,4 +92,6 @@ var port = options.port; | ||
if (message === null) return; | ||
console.log('\nMEGASERVER Get msg:'); | ||
console.log(message); | ||
if (!true){ | ||
console.log('\nMEGASERVER Get msg:'); | ||
console.log(message); | ||
} | ||
if (message.action == 'Hi'){ | ||
@@ -103,3 +133,3 @@ console.log('Hi'); | ||
} | ||
if (!pathChceker.existsSync(options.path2watch)){ | ||
if (!fs.existsSync(options.path2watch)){ | ||
if (megaServerTrans !=- null ){ | ||
@@ -106,0 +136,0 @@ megaServerTrans.publish('/'+serverDefaultChannel+"/serverCreatedError", {error:'path', errorTxt:'Please write a correct path', init:false, created:false}); |
{ | ||
"name": "watchers", | ||
"version": "0.2.24", | ||
"version": "0.3.26", | ||
"description": "Watch file changes and refresh site in browser", | ||
@@ -19,2 +19,3 @@ "main": "lib/main.js", | ||
"optimist": "0.3.5", | ||
"portscanner": "0.1.3", | ||
"faye": "0.8.6" | ||
@@ -21,0 +22,0 @@ }, |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
20268
477
5
3
1
+ Addedportscanner@0.1.3
+ Addedasync@0.1.15(transitive)
+ Addedportscanner@0.1.3(transitive)