Skip to content

Commit

Permalink
Use global PouchDB object instead of requiring module (#10)
Browse files Browse the repository at this point in the history
This makes it easier to use in the browser: just add a script tag with
the hosted pouchdb.min.js. It also makes it easier to use custom
builds of PouchDB, like the pouchdb-node or pouchdb-browser builds.

To be revisited when JavaScript modules are less of a mess. Surprised
as I am, this seems like a problem functors (ML-style, on the module
level) would solve.

Also in this commit:
- test against PouchDB to 6.4.2
- use make instead of pulp for building and running tests
  • Loading branch information
fehrenbach authored Feb 17, 2018
1 parent 1085f81 commit dbfa2bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ install:
- npm install -g bower purescript pulp
- npm install [email protected]
script:
- bower install --production
- pulp build
- bower install
- pulp test
- make test
after_success:
- test $TRAVIS_TAG &&
echo $GITHUB_TOKEN | pulp login &&
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: test

SOURCES = $(shell find src/)
TEST_SOURCES = $(shell find test/)

output/Test.Main/index.js: $(SOURCES) $(TEST_SOURCES)
purs compile 'bower_components/*/src/**/*.purs' 'src/**/*.purs' 'test/**/*.purs'

test: output/Test.Main/index.js
node -e 'global.PouchDB = require("pouchdb");require("./output/Test.Main").main()'
8 changes: 3 additions & 5 deletions src/Database/PouchDB/FFI.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";

const _pouchdb = require('pouchdb');

function callback (e, r) {
return function (err, response) {
if (err)
Expand All @@ -20,7 +18,7 @@ function nonCanceller() {

exports.pouchDB = function (options) {
return function () {
return new _pouchdb(options);
return new PouchDB(options);
}}

exports.destroy = function (db) {
Expand Down Expand Up @@ -87,7 +85,7 @@ exports.replicate = function (source) {
return function (target) {
return function (options) {
return function () {
return _pouchdb.replicate(source, target, options);
return PouchDB.replicate(source, target, options);
}}}}

exports.replicateTo = function (source) {
Expand All @@ -105,7 +103,7 @@ exports.sync = function (source) {
return function (target) {
return function (options) {
return function () {
return _pouchdb.sync(source, target, options);
return PouchDB.sync(source, target, options);
}}}}

exports.putAttachment = function (db) {
Expand Down

0 comments on commit dbfa2bc

Please sign in to comment.