diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bd6b9b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +#!/bin/make -f +# -*- makefile -*- +# SPDX-License-Identifier: MIT + +default: help all + @echo "log: $@: $^" + +tmp_dir ?= tmp +runtime ?= iotjs +export runtime +srcs_dir ?= lib example +srcs ?= $(wildcard *.js | sort | uniq) + +main_src ?= example/index.js + + +help: + @echo "## Usage: " + @echo "# make start" + +setup: setup/${runtime} + +start/%: ${main_src} + ${@F} $< ${run_args} + +start: start/${runtime} + +clean: + rm -rf ${tmp_dir} + +cleanall: clean + rm -f *~ + +distclean: cleanall + rm -rf node_modules + +setup/iotjs: ${iotjs_modules_dir} + @echo "Expected to see IoT.js' help" + ${@F} --help ||: + ls $< diff --git a/bh1750.js b/bh1750.js index 098b2ad..1efeffd 100644 --- a/bh1750.js +++ b/bh1750.js @@ -1,5 +1,11 @@ var console = require('console'); -var i2c = require('i2c'); + +var i2c = null; +try { + i2c = require('@abandonware/i2c'); +} catch(err) { + i2c = require('i2c'); +} var BH1750 = function (opts) { this.options = opts || { diff --git a/package.json b/package.json index 71293ea..7c1fe4e 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "version": "0.0.6", "main": "bh1750", "scripts": { + "start": "node example", "test": "node example", "lint": "eslint ." }, @@ -13,7 +14,7 @@ "url": "https://github.com/miroRucka/bh1750" }, "dependencies": { - "@abandonware/i2c": "^0.2.4-0" + "@abandonware/i2c": "^0.2.4-1" }, "keywords": [ "raspberry, raspberry pi, light, sensor, bh1750, ambient-light, iotjs-module" @@ -25,7 +26,7 @@ } ], "devDependencies": { - "eslint": "^5.4.0" + "eslint": "^6.8.0" }, "iotjs": { "version": ">=1.0"