From d9c551c0268404dc70d85b3c4316dd3d6776eab3 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Wed, 2 Nov 2016 09:55:06 +0000 Subject: [PATCH] Fix SensorTag node on Windows (#246) Fix windows install (or rather - only run the postinstall if on Linux) Thanks @hardillb --- hardware/sensorTag/package.json | 4 ++-- hardware/sensorTag/scripts/checkplatform.js | 17 +++++++++++++++++ hardware/sensorTag/scripts/pibt.sh | 8 +++----- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 hardware/sensorTag/scripts/checkplatform.js diff --git a/hardware/sensorTag/package.json b/hardware/sensorTag/package.json index cd21ff54..cdd7b132 100644 --- a/hardware/sensorTag/package.json +++ b/hardware/sensorTag/package.json @@ -1,7 +1,7 @@ { "name": "node-red-node-sensortag", "description": "A Node-RED node to read data from a TI SensorTag", - "version": "0.0.16", + "version": "0.0.17", "keywords": [ "node-red", "sensortag", @@ -12,7 +12,7 @@ "sensortag": "~1.2.0" }, "scripts" : { - "postinstall" : "scripts/pibt.sh" + "postinstall" : "node scripts/checkplatform.js pibt.sh" }, "license": "Apache-2.0", "repository": { diff --git a/hardware/sensorTag/scripts/checkplatform.js b/hardware/sensorTag/scripts/checkplatform.js new file mode 100644 index 00000000..59b8cf1e --- /dev/null +++ b/hardware/sensorTag/scripts/checkplatform.js @@ -0,0 +1,17 @@ +var spawn = require('child_process').spawn; + +if (process.argv.length === 3) { + var command = process.argv[2]; + + if (process.platform === 'linux') { + var dir = __dirname; + var script = spawn(dir + "/" + command); + script.on('close',function(code){ + process.exit(code); + }); + } else { + process.exit(0); + } +} else { + process.exit(0); +} \ No newline at end of file diff --git a/hardware/sensorTag/scripts/pibt.sh b/hardware/sensorTag/scripts/pibt.sh index 9f78db66..d4acebbc 100755 --- a/hardware/sensorTag/scripts/pibt.sh +++ b/hardware/sensorTag/scripts/pibt.sh @@ -1,6 +1,4 @@ #!/bin/bash -if grep -q ARM /proc/cpuinfo -then - sudo apt-get install libbluetooth-dev libudev-dev pi-bluetooth - sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) -fi +#sudo apt-get install libbluetooth-dev libudev-dev pi-bluetooth + sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) +