From 43a822b7aa383788c73578c28ee69c5f7f020a2d Mon Sep 17 00:00:00 2001 From: robsonbittencourt Date: Sat, 27 May 2017 17:36:08 -0300 Subject: [PATCH 1/2] Fix gear path --- package.json | 2 +- src/db.js | 4 ++-- test/db.js | 13 +++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0261fc4..975b248 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "chai-as-promised": "^6.0.0", "sinon": "^1.17.7", "sinon-as-promised": "^4.0.3", - "mocha": "^3.4.1", + "mocha": "^3.4.2", "proxyquire": "^1.8.0", "istanbul": "^0.4.5", "coveralls": "^2.13.1", diff --git a/src/db.js b/src/db.js index e57057b..7076054 100644 --- a/src/db.js +++ b/src/db.js @@ -2,8 +2,8 @@ exports.getDb = getDb; -const sqlite = require('sqlite'); const path = require('path'); +const sqlite = require('sqlite'); let database; @@ -38,5 +38,5 @@ function migrate(sqliteDb) { } function gearPath() { - return path.resolve(process.cwd(), 'node_modules/gear-jenkins/'); + return path.resolve(__dirname, '../'); } diff --git a/test/db.js b/test/db.js index cc89e76..ac2fa48 100644 --- a/test/db.js +++ b/test/db.js @@ -3,6 +3,7 @@ 'use strict'; require('sinon-as-promised'); +const path = require('path'); const sinon = require('sinon'); const expect = require('chai').expect; const proxyquire = require('proxyquire').noPreserveCache(); @@ -23,11 +24,13 @@ describe('Data base creation', () => { db.getDb(); - expect(openSpy.calledWith(`${process.cwd()}/node_modules/gear-jenkins/gear-jenkins.sqlite`)).to.be.true; + const basePath = path.resolve(__dirname, '../'); + + expect(openSpy.calledWith(`${basePath}/gear-jenkins.sqlite`)).to.be.true; migrateSpy().then(() => { expect(migrateSpy.calledWithMatch( - { migrationsPath: `${process.cwd()}/node_modules/gear-jenkins/migrations` })).to.be.true; + { migrationsPath: `${basePath}/migrations` })).to.be.true; }); }); @@ -43,9 +46,11 @@ describe('Data base creation', () => { db.getDb(); - expect(openSpy.calledWith(`${process.cwd()}/node_modules/gear-jenkins/gear-jenkins.sqlite`)).to.be.true; + const basePath = path.resolve(__dirname, '../'); + + expect(openSpy.calledWith(`${basePath}/gear-jenkins.sqlite`)).to.be.true; expect(migrateSpy.calledWithMatch( - { migrationsPath: `${process.cwd()}/node_modules/gear-jenkins/migrations` })).to.be.false; + { migrationsPath: `${basePath}/migrations` })).to.be.false; }); it('do nothing when error occurs on migration', () => { From e47fd4614b26227b1680c209150e439b781cd570 Mon Sep 17 00:00:00 2001 From: robsonbittencourt Date: Sat, 27 May 2017 17:42:03 -0300 Subject: [PATCH 2/2] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 975b248..a804e45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gear-jenkins", - "version": "2.1.0", + "version": "2.1.1", "description": "A Hubot Gear for handle Jenkins tasks", "main": "/src/jenkins.js", "scripts": {