diff --git a/package.json b/package.json index 7d1a23d2..621717a0 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "JSONStream": "~0.7.1", + "blinker": "git+ssh://git@bitbucket.org:rulemotion/blinker.git#v0.0.1", "bluebird": "^2.6.0", "coffee-script": "~1.8.0", "csr-gen": "~0.2.1", diff --git a/src/lib/blink.coffee b/src/lib/blink.coffee deleted file mode 100644 index 9001330e..00000000 --- a/src/lib/blink.coffee +++ /dev/null @@ -1,43 +0,0 @@ -Promise = require 'bluebird' -fs = Promise.promisifyAll require 'fs' - -# Helps in blinking the LED from the given end point. -module.exports = exports = (ledFile) -> - ledOn = -> - fs.writeFileAsync(ledFile, 1) - ledOff = -> - fs.writeFileAsync(ledFile, 0) - - blink = (ms = 200) -> - ledOn() - .delay(ms) - .then(ledOff) - - blink.pattern = do -> - blinking = null - start = (pattern) -> - Promise.resolve([0...pattern.blinks]).cancellable() - .each -> - blink(pattern.onDuration) - .delay(pattern.offDuration) - .delay(pattern.pause) - .then -> - start(pattern) - return { - start: (pattern = {}) -> - return false if blinking? - fullPattern = - blinks: pattern.blinks ? 1 - onDuration: pattern.onDuration ? 200 - offDuration: pattern.offDuration ? 200 - pause: pattern.pause ? 0 - blinking = start(fullPattern) - return - stop: -> - return false if not blinking? - blinking.cancel().catch(Promise.CancellationError, ->) - ledOff() - blinking = null - } - - return blink \ No newline at end of file diff --git a/src/utils.coffee b/src/utils.coffee index 7643e06e..2564f0e0 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -5,7 +5,7 @@ config = require './config' mixpanel = require 'mixpanel' request = require './request' networkCheck = require './lib/network-check' -blink = require('./lib/blink')(config.ledFile) +blink = require('blinker')(config.ledFile) utils = exports