diff --git a/index.js b/index.js index 83242d7..7ce8dc2 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,7 @@ class S3Notifier { this.ui = options.ui; this.bucket = options.bucket; this.key = options.key; + this.notifiers = []; this.pollTime = options.poll || DEFAULT_POLL_TIME; this.params = { @@ -23,7 +24,7 @@ class S3Notifier { } subscribe(notify) { - this.notify = notify; + this.notifiers.push(notify); return this.getCurrentLastModified() .then(() => this.schedulePoll()); @@ -54,10 +55,10 @@ class S3Notifier { } compareLastModifieds(newLastModified) { - if (newLastModified !== this.lastModified) { + if ((newLastModified + '') !== (this.lastModified + '')) { this.ui.writeLine('config modified; old=%s; new=%s', this.lastModified, newLastModified); this.lastModified = newLastModified; - this.notify(); + this.notifiers.forEach(notifier => notifier(newLastModified)); } } } diff --git a/package.json b/package.json index b269da1..ae58cd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fastboot-s3-notifier", - "version": "0.1.1", + "version": "0.1.2", "description": "A FastBoot App Server notifier for AWS S3", "main": "index.js", "scripts": {