Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/738#discussion_r70444882
--- Diff: bin/remove-test-dbs.js ---
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+const fs = require('fs');
+
+const settingsFilePath = './settings.json';
+const settingsFile = fs.existsSync(settingsFilePath) ? settingsFilePath :
'./settings.json.default.json';
+const settings = JSON.parse(fs.readFileSync(settingsFile)).nightwatch;
+const dbUrl =
`http://${settings.fauxton_username}:${settings.password}@${settings.db_host}:${settings.db_port}`;
+const nano = require('nano')(dbUrl);
+
+nano.db.list((err, body) => {
+ if (err) {
+ console.log('ERR', err);
+ return;
+ }
+ const out = body.forEach(db => {
--- End diff --
the forEach loop handles async code (removing the dbs) in a sync fashion
and logs error related output to stdout instead of stderr. to fix that, use
console.error. for the sync issue you can use
https://github.com/caolan/async/blob/v1.5.2/README.md#parallel (we require the
module async already in other parts of our build-related infrastructure).
example (not tested):
```js
const list = body.filter(db => {
return /fauxton-selenium-tests/.test(db);
});
list.map(db => {
return function (err, cb) {
nano.db.destroy(db, (err, resp) => {
if (err) {
return cb(err);
}
cb(null);
})
}
});
async.parallel(list, () => {
if (err) {
console.error(err);
}
})
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---