Skip to content

Commit 9e71c2a

Browse files
committed
adjust to cs
1 parent d811fae commit 9e71c2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1553
-1984
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "standard",
33
"rules": {
44
"semi": ["error", "always"],
5-
"no-unused-vars": "warn"
5+
"no-unused-vars": "warn",
66
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }]
77
}
88
}

.tern-port

Lines changed: 0 additions & 1 deletion
This file was deleted.

api.js

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ var onComplete = load('on-complete');
88

99
// constant hooks for this file
1010
var APIHooks = {
11-
'init:api:addfunction:hook': function(name, fn) {
11+
'init:api:addfunction:hook': function (name, fn) {
1212
this[name] = fn;
13-
return;
1413
},
15-
'init:api:accessapi:hook': function(cb) {
14+
'init:api:accessapi:hook': function (cb) {
1615
return cb(this);
1716
}
1817
};
1918

20-
function dbmigrate(plugins, isModule, options, callback) {
19+
function dbmigrate (plugins, isModule, options, callback) {
2120
var dotenv = require('dotenv');
2221
var setDefaultArgv = load('set-default-argv');
2322

@@ -44,10 +43,7 @@ function dbmigrate(plugins, isModule, options, callback) {
4443
/* $lab:coverage:on$ */
4544

4645
if (typeof options === 'object') {
47-
if (typeof options.config === 'string')
48-
internals.configFile = options.config;
49-
else if (typeof options.config === 'object')
50-
internals.configObject = options.config;
46+
if (typeof options.config === 'string') { internals.configFile = options.config; } else if (typeof options.config === 'object') { internals.configObject = options.config; }
5147

5248
if (typeof options.env === 'string') internals.currentEnv = options.env;
5349

@@ -65,7 +61,7 @@ function dbmigrate(plugins, isModule, options, callback) {
6561
this.internals
6662
);
6763

68-
//delayed loading of bluebird
64+
// delayed loading of bluebird
6965
Promise = require('bluebird');
7066
this.internals.migrationOptions = {
7167
dbmigrate: this.internals.dbm,
@@ -85,7 +81,7 @@ dbmigrate.prototype = {
8581
*
8682
* @return boolean
8783
*/
88-
addGlobal: function(library) {
84+
addGlobal: function (library) {
8985
try {
9086
require(library);
9187
} catch (e) {
@@ -100,22 +96,22 @@ dbmigrate.prototype = {
10096
*
10197
* @returns Promise
10298
*/
103-
registerAPIHook: function(callback) {
99+
registerAPIHook: function (callback) {
104100
var plugins = this.internals.plugins;
105101
var self = this;
106102

107103
return Promise.resolve(Object.keys(APIHooks))
108-
.each(function(hook) {
104+
.each(function (hook) {
109105
var plugin = plugins.hook(hook);
110106
if (!plugin) return;
111107

112108
var APIHook = APIHooks[hook].bind(self);
113109

114110
return Promise.resolve(plugin)
115-
.map(function(plugin) {
111+
.map(function (plugin) {
116112
return plugin[hook]();
117113
})
118-
.each(function(args) {
114+
.each(function (args) {
119115
return APIHook.apply(self, args);
120116
});
121117
})
@@ -129,7 +125,7 @@ dbmigrate.prototype = {
129125
*
130126
* @return boolean
131127
*/
132-
addConfiguration: function(description, args, type) {
128+
addConfiguration: function (description, args, type) {
133129
var name = args.shift();
134130
this.internals.argv.describe(name, description);
135131

@@ -156,7 +152,7 @@ dbmigrate.prototype = {
156152
/**
157153
* Resets and sets argv to a specified new argv.
158154
*/
159-
resetConfiguration: function(argv) {
155+
resetConfiguration: function (argv) {
160156
this.internals.argv = argv;
161157
},
162158

@@ -165,7 +161,7 @@ dbmigrate.prototype = {
165161
*
166162
* Defaults to up all migrations if no count is given.
167163
*/
168-
up: function(specification, opts, callback) {
164+
up: function (specification, opts, callback) {
169165
var executeUp = load('up');
170166

171167
if (arguments.length > 0) {
@@ -186,7 +182,7 @@ dbmigrate.prototype = {
186182
}
187183

188184
return Promise.fromCallback(
189-
function(callback) {
185+
function (callback) {
190186
executeUp(this.internals, this.config, callback);
191187
}.bind(this)
192188
).asCallback(callback);
@@ -197,7 +193,7 @@ dbmigrate.prototype = {
197193
*
198194
* Defaults to up all migrations if no count is given.
199195
*/
200-
down: function(specification, opts, callback) {
196+
down: function (specification, opts, callback) {
201197
var executeDown = load('down');
202198

203199
if (arguments.length > 0) {
@@ -216,7 +212,7 @@ dbmigrate.prototype = {
216212
}
217213

218214
return Promise.fromCallback(
219-
function(callback) {
215+
function (callback) {
220216
executeDown(this.internals, this.config, callback);
221217
}.bind(this)
222218
).asCallback(callback);
@@ -227,7 +223,7 @@ dbmigrate.prototype = {
227223
*
228224
* Defaults to up all migrations if no count is given.
229225
*/
230-
sync: function(specification, opts, callback) {
226+
sync: function (specification, opts, callback) {
231227
var executeSync = load('sync');
232228

233229
if (arguments.length > 0) {
@@ -244,7 +240,7 @@ dbmigrate.prototype = {
244240
}
245241

246242
return Promise.fromCallback(
247-
function(callback) {
243+
function (callback) {
248244
executeSync(this.internals, this.config, callback);
249245
}.bind(this)
250246
).asCallback(callback);
@@ -253,7 +249,7 @@ dbmigrate.prototype = {
253249
/**
254250
* Executes down for all currently migrated migrations.
255251
*/
256-
reset: function(scope, callback) {
252+
reset: function (scope, callback) {
257253
var executeDown = load('down');
258254

259255
if (typeof scope === 'string') {
@@ -265,7 +261,7 @@ dbmigrate.prototype = {
265261

266262
this.internals.argv.count = Number.MAX_VALUE;
267263
return Promise.fromCallback(
268-
function(callback) {
264+
function (callback) {
269265
executeDown(this.internals, this.config, callback);
270266
}.bind(this)
271267
).asCallback(callback);
@@ -274,21 +270,21 @@ dbmigrate.prototype = {
274270
/**
275271
* Silence the log output completely.
276272
*/
277-
silence: function(isSilent) {
273+
silence: function (isSilent) {
278274
return log.silence(isSilent);
279275
},
280276

281277
/**
282278
* Transition migrations to the latest defined protocol.
283279
*/
284-
transition: function() {
280+
transition: function () {
285281
transition(this.internals);
286282
},
287283

288284
/**
289285
* Creates a correctly formatted migration
290286
*/
291-
create: function(migrationName, scope, callback) {
287+
create: function (migrationName, scope, callback) {
292288
var executeCreateMigration = load('create-migration');
293289
if (typeof scope === 'function') {
294290
callback = scope;
@@ -299,7 +295,7 @@ dbmigrate.prototype = {
299295

300296
this.internals.argv._.push(migrationName);
301297
return Promise.fromCallback(
302-
function(callback) {
298+
function (callback) {
303299
executeCreateMigration(this.internals, this.config, callback);
304300
}.bind(this)
305301
).asCallback(callback);
@@ -308,12 +304,12 @@ dbmigrate.prototype = {
308304
/**
309305
* Creates a database of the given dbname.
310306
*/
311-
createDatabase: function(dbname, callback) {
307+
createDatabase: function (dbname, callback) {
312308
var executeDB = load('db');
313309
this.internals.argv._.push(dbname);
314310
this.internals.mode = 'create';
315311
return Promise.fromCallback(
316-
function(callback) {
312+
function (callback) {
317313
executeDB(this.internals, this.config, callback);
318314
}.bind(this)
319315
).asCallback(callback);
@@ -322,12 +318,12 @@ dbmigrate.prototype = {
322318
/**
323319
* Drops a database of the given dbname.
324320
*/
325-
dropDatabase: function(dbname, callback) {
321+
dropDatabase: function (dbname, callback) {
326322
var executeDB = load('db');
327323
this.internals.argv._.push(dbname);
328324
this.internals.mode = 'drop';
329325
return Promise.fromCallback(
330-
function(callback) {
326+
function (callback) {
331327
executeDB(this.internals, this.config, callback);
332328
}.bind(this)
333329
).asCallback(callback);
@@ -338,30 +334,30 @@ dbmigrate.prototype = {
338334
*
339335
* @return value
340336
*/
341-
setConfigParam: function(param, value) {
337+
setConfigParam: function (param, value) {
342338
return (this.internals.argv[param] = value);
343339
},
344340

345341
/**
346342
* Sets the callback to the default onComplete
347343
*/
348-
setDefaultCallback: function() {
344+
setDefaultCallback: function () {
349345
this.internals.onComplete = onComplete;
350346
},
351347

352348
/**
353349
* Let's the user customize the callback, which gets called after all
354350
* migrations have been done.
355351
*/
356-
setCustomCallback: function(callback) {
352+
setCustomCallback: function (callback) {
357353
this.internals.onComplete = callback;
358354
},
359355

360356
/**
361357
* Seeds either the static or version controlled seeders, controlled by
362358
* the passed mode.
363359
*/
364-
seed: function(mode, scope, callback) {
360+
seed: function (mode, scope, callback) {
365361
var executeSeed = load('seed');
366362
if (scope) {
367363
this.internals.migrationMode = scope;
@@ -370,7 +366,7 @@ dbmigrate.prototype = {
370366

371367
this.internals.mode = mode || 'vc';
372368
return Promise.fromCallback(
373-
function(callback) {
369+
function (callback) {
374370
executeSeed(this.internals, this.config, callback);
375371
}.bind(this)
376372
).asCallback(callback);
@@ -379,7 +375,7 @@ dbmigrate.prototype = {
379375
/**
380376
* Execute the down function of currently executed seeds.
381377
*/
382-
undoSeed: function(specification, scope, callback) {
378+
undoSeed: function (specification, scope, callback) {
383379
var executeUndoSeed = load('undo-seed');
384380
if (arguments.length > 0) {
385381
if (typeof specification === 'number') {
@@ -396,7 +392,7 @@ dbmigrate.prototype = {
396392
}
397393

398394
return Promise.fromCallback(
399-
function(callback) {
395+
function (callback) {
400396
executeUndoSeed(this.internals, this.config, callback);
401397
}.bind(this)
402398
).asCallback(callback);
@@ -405,7 +401,7 @@ dbmigrate.prototype = {
405401
/**
406402
* Execute the reset function of currently executed seeds.
407403
*/
408-
resetSeed: function(specification, scope, callback) {
404+
resetSeed: function (specification, scope, callback) {
409405
var executeUndoSeed = load('undo-seed');
410406
if (arguments.length > 0) {
411407
if (typeof specification === 'number') {
@@ -423,7 +419,7 @@ dbmigrate.prototype = {
423419

424420
this.internals.argv.count = Number.MAX_VALUE;
425421
return Promise.fromCallback(
426-
function(callback) {
422+
function (callback) {
427423
executeUndoSeed(this.internals, this.config, callback);
428424
}.bind(this)
429425
).asCallback(callback);
@@ -432,7 +428,7 @@ dbmigrate.prototype = {
432428
/**
433429
* Executes the default routine.
434430
*/
435-
run: function() {
431+
run: function () {
436432
load('run')(this.internals, this.config);
437433
}
438434
};

bin/db-migrate

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
#!/usr/bin/env node
22

3-
var resolve = require( 'resolve' );
3+
var resolve = require('resolve');
44
var log = require('db-migrate-shared').log;
55

66
process.title = 'db-migrate';
7-
if ( process.argv.indexOf( '--verbose' ) !== -1 ||
8-
process.argv.indexOf( '-v' ) !== -1
9-
)
10-
global.verbose = true;
7+
if (process.argv.indexOf('--verbose') !== -1 ||
8+
process.argv.indexOf('-v') !== -1
9+
) { global.verbose = true; }
1110

12-
resolve( 'db-migrate', {
11+
resolve('db-migrate', {
1312

1413
basedir: process.cwd()
15-
}, function ( error, localModule ) {
16-
14+
}, function (error, localModule) {
1715
var DBMigrate, dbmigrate;
1816

19-
if ( error ) {
20-
DBMigrate = require( '../' );
21-
}
22-
else {
23-
DBMigrate = require( localModule );
24-
log.verbose( 'Detected and using the projects local version of db-migrate. ' +
17+
if (error) {
18+
DBMigrate = require('../');
19+
} else {
20+
DBMigrate = require(localModule);
21+
log.verbose('Detected and using the projects local version of db-migrate. ' +
2522
'\'' + localModule + '\'');
2623
}
2724

28-
if ( typeof( DBMigrate.getInstance ) !== 'function' ) {
29-
DBMigrate = require( '../' );
25+
if (typeof (DBMigrate.getInstance) !== 'function') {
26+
DBMigrate = require('../');
3027

31-
log.warn( 'Using global instead of local detected version as you have a ' +
32-
'version older than 0.10.0 in your projects package.json!' );
28+
log.warn('Using global instead of local detected version as you have a ' +
29+
'version older than 0.10.0 in your projects package.json!');
3330
}
3431

3532
dbmigrate = DBMigrate.getInstance();
36-
if(dbmigrate.registerAPIHook)
33+
if (dbmigrate.registerAPIHook) {
3734
dbmigrate.registerAPIHook()
38-
.then( function() {
39-
40-
dbmigrate.run();
41-
} );
42-
else
43-
dbmigrate.run();
44-
} );
35+
.then(function () {
36+
dbmigrate.run();
37+
});
38+
} else { dbmigrate.run(); }
39+
});

0 commit comments

Comments
 (0)