From 2ed59676897c6be5dafa4327a4664d326b1f276d Mon Sep 17 00:00:00 2001 From: Tobias Gurtzick Date: Wed, 22 Jun 2016 23:00:54 +0200 Subject: [PATCH] refactor(log): move log into new extern lib Refers to #382 --- api.js | 2 +- bin/db-migrate | 2 +- connect.js | 2 +- lib/driver/index.js | 2 +- lib/migration.js | 2 +- lib/migrator.js | 2 +- lib/relation.js | 2 +- lib/seed.js | 2 +- lib/seeder.js | 2 +- lib/util.js | 2 +- package.json | 1 + test/driver/base_test.js | 2 +- test/driver/mysql_test.js | 2 +- test/driver/pg_test.js | 2 +- 14 files changed, 14 insertions(+), 13 deletions(-) diff --git a/api.js b/api.js index 96be2ed5..e7470b3b 100644 --- a/api.js +++ b/api.js @@ -8,7 +8,7 @@ var index = require('./connect'); var Migration = require('./lib/migration.js'); var Seeder = require('./lib/seeder.js'); var Migrator = require('./lib/migrator.js'); -var log = require('./lib/log'); +var log = require('db-migrate-shared').log; var pkginfo = require('pkginfo')(module, 'version'); // jshint ignore:line var dotenv = require('dotenv'); var Promise = require('bluebird'); diff --git a/bin/db-migrate b/bin/db-migrate index 106004a7..33c4d2de 100755 --- a/bin/db-migrate +++ b/bin/db-migrate @@ -1,7 +1,7 @@ #!/usr/bin/env node var resolve = require( 'resolve' ); -var log = require( '../lib/log.js' ); +var log = require('db-migrate-shared').log; process.title = 'db-migrate'; diff --git a/connect.js b/connect.js index 22c0234a..8ee73de4 100644 --- a/connect.js +++ b/connect.js @@ -2,7 +2,7 @@ var recursive = require('final-fs').readdirRecursive; var fs = require('fs'); var driver = require('./lib/driver'); var path = require('path'); -var log = require('./lib/log'); +var log = require('db-migrate-shared').log; var internals = {}; diff --git a/lib/driver/index.js b/lib/driver/index.js index adb336ec..6f6f54cd 100644 --- a/lib/driver/index.js +++ b/lib/driver/index.js @@ -1,7 +1,7 @@ var internals = {}; internals.mod = internals.mod || {}; -internals.mod.log = require('../log'); +internals.mod.log = require('db-migrate-shared').log; internals.mod.type = require('../data_type'); var Shadow = require('./shadow'); var log = internals.mod.log; diff --git a/lib/migration.js b/lib/migration.js index d581ffac..eecfdd92 100644 --- a/lib/migration.js +++ b/lib/migration.js @@ -1,6 +1,6 @@ var fs = require('fs'); var path = require('path'); -var log = require('./log'); +var log = require('db-migrate-shared').log; var Skeleton = require('./skeleton'); var filesRegEx = /\.js$/; diff --git a/lib/migrator.js b/lib/migrator.js index ee5caad0..ff554f1a 100644 --- a/lib/migrator.js +++ b/lib/migrator.js @@ -1,6 +1,6 @@ var dbmUtil = require('./util'); var Migration = require('./migration'); -var log = require('./log'); +var log = require('db-migrate-shared').log; var Promise = require('bluebird'); var MigratorInterface = require( './interface/migratorInterface.js'); diff --git a/lib/relation.js b/lib/relation.js index 20f74905..01ae1cb9 100644 --- a/lib/relation.js +++ b/lib/relation.js @@ -1,5 +1,5 @@ var fs = require('fs'), - log = require('./log'); + log = require('db-migrate-shared').log; function Relation() { this.relations = {}; diff --git a/lib/seed.js b/lib/seed.js index 13775531..f0a3fd96 100644 --- a/lib/seed.js +++ b/lib/seed.js @@ -1,6 +1,6 @@ var fs = require('fs'); var path = require('path'); -var log = require('./log'); +var log = require('db-migrate-shared').log; var Skeleton = require('./skeleton'); var filesRegEx = /\.js$/; diff --git a/lib/seeder.js b/lib/seeder.js index 15980530..d84d0fde 100644 --- a/lib/seeder.js +++ b/lib/seeder.js @@ -1,5 +1,5 @@ var Seed = require('./seed'); -var log = require('./log'); +var log = require('db-migrate-shared').log; var dbmUtil = require('./util'); var Promise = require('bluebird'); var SeederInterface = require( './interface/seederInterface.js'); diff --git a/lib/util.js b/lib/util.js index 2d12055f..c8a31353 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,4 +1,4 @@ -var log = require('./log'); +var log = require('db-migrate-shared').log; function isIncludedInUp(migration, destination) { if(!destination) { diff --git a/package.json b/package.json index d403d71a..ca832968 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "dependencies": { "async": "^1.0.0", "bluebird": "^3.1.1", + "db-migrate-shared": "^1.0.2", "dotenv": "~1.2.0", "final-fs": "^1.6.0", "mkdirp": "~0.5.0", diff --git a/test/driver/base_test.js b/test/driver/base_test.js index 6a0d0d4c..d5badb19 100644 --- a/test/driver/base_test.js +++ b/test/driver/base_test.js @@ -5,7 +5,7 @@ var Base = require('db-migrate-base'); var internals = { migrationTable: 'migrations', mod: { - log: require('../../lib/log.js'), + log: require('db-migrate-shared').log, type: require('../../lib/data_type.js') } }; diff --git a/test/driver/mysql_test.js b/test/driver/mysql_test.js index fe29af1a..13500e80 100644 --- a/test/driver/mysql_test.js +++ b/test/driver/mysql_test.js @@ -3,7 +3,7 @@ var assert = require('assert'); var dbmeta = require('db-meta'); var dataType = require('../../lib/data_type'); var driver = require('../../lib/driver'); -var log = require('../..//lib/log.js'); +var log = require('db-migrate-shared').log; var config = require('../db.config.json').mysql; diff --git a/test/driver/pg_test.js b/test/driver/pg_test.js index 55b60ba8..d284270c 100644 --- a/test/driver/pg_test.js +++ b/test/driver/pg_test.js @@ -4,7 +4,7 @@ var assert = require('assert'); var dbmeta = require('db-meta'); var dataType = require('../../lib/data_type'); var driver = require('../../lib/driver'); -var log = require('../..//lib/log.js'); +var log = require('db-migrate-shared').log; var config = require('../db.config.json').pg;