Skip to content

Commit

Permalink
Merge pull request #102 from langpavel/prepare-3.1
Browse files Browse the repository at this point in the history
v3.1
  • Loading branch information
langpavel committed Jul 29, 2017
2 parents 8a1c54e + 6568eeb commit a3fd88a
Show file tree
Hide file tree
Showing 6 changed files with 3,505 additions and 29 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
language: node_js
node_js:
- "7"
- "8"
- "6"
- "5"
- "4"
services:
- postgresql
env:
- CC=clang CXX=clang++ npm_config_clang=1 PGUSER=postgres PGDATABASE=postgres

install:
- npm install -g node-gyp
- npm install

script:
- gulp lint
- gulp build
- gulp test

sudo: false
addons:
postgresql: "9.4"
Expand All @@ -17,6 +25,6 @@ addons:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
after_script:
after_success:
- npm install coveralls
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async function doTheWork() {
#### `pgAsync.closeConnections()`

* Disconnects all idle clients within all active pools, and has all client pools terminate.
See [`pg.end()`](https://github.com/brianc/node-postgres/wiki/pg#end)
See [`pool.end()`](https://node-postgres.com/api/pool#pool-end)
* This actually terminates all connections on driver used by Pg instance

---
Expand Down
8 changes: 4 additions & 4 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const runEslint = () =>
.pipe(eslint.format())
.pipe(eslint.failAfterError());

gulp.task('clean', () => del('lib/*'));
gulp.task('clean', () => del('lib/*.js'));

gulp.task('eslint', () => runEslint());

gulp.task('lint', ['eslint']);

gulp.task('test', ['eslint'], (done) => {
gulp.task('test', ['lint', 'build'], (done) => {
gulp.src(['src/*.js'])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
Expand All @@ -37,11 +37,11 @@ gulp.task('test', ['eslint'], (done) => {
});
});

gulp.task('build', ['test'], () => {
gulp.task('build', ['clean', 'lint'], () => {
gulp.src('src/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
});

// Default task to start development. Just type gulp.
gulp.task('default', ['build', 'test']);
gulp.task('default', ['clean', 'lint', 'build', 'test']);
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "pg-async",
"version": "3.0.0",
"version": "3.1.0",
"description": "PostgreSQL client for node.js designed for usage with ES7 async/await based on node-postgres (pg) module",
"main": "lib/index.js",
"scripts": {
"test": "gulp test",
"test": "gulp",
"lint": "gulp eslint"
},
"repository": {
Expand Down Expand Up @@ -35,30 +35,30 @@
},
"homepage": "https://github.com/langpavel/node-pg-async#readme",
"dependencies": {
"bluebird": "^3.4.6",
"bluebird": "^3.5.0",
"debug": "^2.6.3",
"pg": "^6.1.4"
"pg": "^7.0.2"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.24.0",
"babel-eslint": "^7.1.1",
"babel": "^6.23.0",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015-node5": "^1.2.0",
"babel-preset-stage-1": "^6.5.0",
"babel-register": "^6.24.0",
"babel-preset-stage-1": "^6.24.1",
"babel-register": "^6.24.1",
"chai": "^3.5.0",
"del": "^2.2.0",
"eslint": "^3.1.1",
"del": "^3.0.0",
"eslint": "^4.2.0",
"eslint-config-strict": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-import": "^2.7.0",
"estraverse-fb": "^1.3.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.0.0",
"gulp-babel-istanbul": "^1.6.0",
"gulp-eslint": "^3.0.1",
"gulp-mocha": "^4.0.1",
"mocha": "^3.0.0",
"pg-native": "^1.10.0"
"gulp-mocha": "^3.0.0",
"mocha": "^3.4.2",
"pg-native": "^2.0.1"
}
}
19 changes: 14 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class PgAsync {
constructor(connectionOptions, driver) {
this.setConnectionOptions(connectionOptions);
this.setDriver(driver);
this.setPool();

const self = this;
const wrap = name => {
Expand Down Expand Up @@ -72,11 +73,20 @@ export default class PgAsync {
return this;
}

setPool() {
const driver = this.getDriver();
const Pool = driver.Pool;
this._pool = new Pool(this.getConnectionOptions());
return this;
}

getPool() {
return this._pool;
}

async getClient() {
return new Promise((resolve, reject) => {
const driver = this.getDriver();
const Pool = driver.Pool;
const pool = new Pool(this.getConnectionOptions());
const pool = this.getPool();
pool.connect((err, client, done) => {
if (err) {
debug('%s getClient(%j)', err, this.getConnectionOptions());
Expand Down Expand Up @@ -131,6 +141,5 @@ export default class PgAsync {
});
}

closeConnections = () => this.getDriver().end();

closeConnections = () => this.getPool().end();
}
Loading

0 comments on commit a3fd88a

Please sign in to comment.