Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extract pouchdb-server setup code Having this code inline in the if-statement that decides what do do based on the $SERVER variable makes this section harder to follow, so I've moved all the setup code into functions that are invoked where needed. * Fix the build order in `bin/run-test.sh` We have been observing that when running `npm test`, the tests don't seem to run the current version of the code. It's possible to make edits to the code, and the first time you run the tests, your edits won't have any effect. They only apply the second time you run the tests. This seems to be because of the order things are done in `bin/run-test.sh`. Depending on the value of `SERVER`, it might start a server using this command: node ./tests/misc/pouchdb-express-router.js This process will import `packages/node_modules/pouchdb`, which in turn imports other packages, whose `main` file is usually `lib/index.js`. This file is not source code but is generated by the build process. After it's started the server, `bin/run-test.sh` then runs one of the test suites, with `test-node` being the default because `CLIENT` defaults to `node`. The npm `test-node` command runs the `build-node` command, which is what triggers the build of all packages and updates their `lib` directories. Because this happens after the server is started, the server is then running out-of-date code. We fix this by putting code in `bin/run-test.sh` to run `npm run build-node` if it's not already been run, before any command that needs the node.js packages up-to-date, and removing the call to `build-node` from the `test-node` command. This should be safe because the only place the `test-node` task is invoked is in `bin/run-test.sh`.
- Loading branch information