Comparing version 1.1.0 to 1.2.1
@@ -28,3 +28,7 @@ var fs = require('fs-extra'); | ||
function setupAndStartDevice(device) { | ||
setupDevice(device, startDevice); | ||
setupDevice(device, function(error, device) { | ||
if (!error) { | ||
startDevice(device); | ||
} | ||
}); | ||
} | ||
@@ -50,2 +54,4 @@ | ||
console.error(error); | ||
callback(error); | ||
return; | ||
} | ||
@@ -56,3 +62,3 @@ fs.copySync(path.join(devicePathTmp, 'node_modules', device.connector), devicePath); | ||
if (callback) { | ||
callback(device); | ||
callback(null, device); | ||
} | ||
@@ -72,3 +78,3 @@ }); | ||
errFile: devicePath + '/forever.stderr', | ||
command: '"' + path.join(config.nodePath, 'npm') + '"' | ||
command: path.join(config.nodePath, 'npm') | ||
}); | ||
@@ -75,0 +81,0 @@ |
36
index.js
@@ -5,7 +5,22 @@ var skynet = require('skynet'); | ||
var skynetConnection = skynet.createConnection({ uuid: config.uuid, token: config.token }); | ||
var deviceManager = require('./device-manager')(config); | ||
var deviceManager = require('./device-manager')({ | ||
uuid: config.uuid, | ||
token: config.token, | ||
devicePath: config.devicePath, | ||
tmpPath: config.tmpPath, | ||
nodePath: config.nodePath | ||
}); | ||
if (!config.uuid) { | ||
skynetConnection.register({type: 'gateway'}, function(data){ | ||
skynetConnection.identify({uuid: data.uuid, token: data.token}); | ||
skynetConnection.on('notReady', function(data) { | ||
console.log('notReady', data); | ||
if (!config.uuid) { | ||
skynetConnection.register({type: 'gateway'}, function(data){ | ||
skynetConnection.identify({uuid: data.uuid, token: data.token}); | ||
}); | ||
} | ||
}); | ||
var refreshDevices = function() { | ||
skynetConnection.whoami({}, function(data){ | ||
deviceManager.refreshDevices(data.devices); | ||
}); | ||
@@ -15,10 +30,13 @@ } | ||
skynetConnection.on('ready', function(data){ | ||
deviceManager.refreshDevices(data.devices); | ||
refreshDevices(); | ||
}); | ||
skynetConnection.on('message', function(message){ | ||
if( deviceManager[message.topic] ) { | ||
deviceManager[message.topic](message.payload); | ||
} | ||
}); | ||
if (message.topic === 'refresh') { | ||
refreshDevices(); | ||
} | ||
if( deviceManager[message.topic] ) { | ||
deviceManager[message.topic](message.payload); | ||
} | ||
}); | ||
}; |
{ | ||
"name": "gatenu-npm", | ||
"version": "1.1.0", | ||
"version": "1.2.1", | ||
"description": "", | ||
@@ -25,3 +25,6 @@ "main": "index.js", | ||
"skynet": "^1.1.1" | ||
}, | ||
"optionalDependencies": { | ||
"commander": "^2.3.0" | ||
} | ||
} |
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
6309
7
126
6