Skip to content

Commit

Permalink
fix(devDeps): updated standard & mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleytodd committed Mar 22, 2022
1 parent 71788e4 commit c07848d
Show file tree
Hide file tree
Showing 41 changed files with 178 additions and 173 deletions.
4 changes: 2 additions & 2 deletions bin/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// vim: set ft=javascript:
'use strict'

var program = require('commander')
var pkg = require('../package.json')
const program = require('commander')
const pkg = require('../package.json')

program
.version(pkg.version)
Expand Down
17 changes: 9 additions & 8 deletions bin/migrate-create
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// vim: set ft=javascript:
'use strict'

var program = require('commander')
var path = require('path')
var dotenv = require('dotenv')
var log = require('../lib/log')
var registerCompiler = require('../lib/register-compiler')
var pkg = require('../package.json')
const program = require('commander')
const path = require('path')
const dotenv = require('dotenv')
const log = require('../lib/log')
const registerCompiler = require('../lib/register-compiler')
const pkg = require('../package.json')

program
.version(pkg.version)
Expand All @@ -30,14 +30,15 @@ if (program.extention) {

// Setup environment
if (program.env) {
var e = dotenv.config({
const e = dotenv.config({
path: typeof program.env === 'string' ? program.env : '.env'
})
if (e && e.error instanceof Error) {
throw e.error
}
}

// eslint-disable-next-line no-var
var _name
function create (name) {
// Name provided?
Expand All @@ -52,7 +53,7 @@ function create (name) {
}

// Load the template generator
var gen
let gen
try {
gen = require(program.generator)
} catch (e) {
Expand Down
24 changes: 12 additions & 12 deletions bin/migrate-down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// vim: set ft=javascript:
'use strict'

var program = require('commander')
var path = require('path')
var minimatch = require('minimatch')
var dotenv = require('dotenv')
var migrate = require('../')
var runMigrations = require('../lib/migrate')
var log = require('../lib/log')
var registerCompiler = require('../lib/register-compiler')
var pkg = require('../package.json')
const program = require('commander')
const path = require('path')
const minimatch = require('minimatch')
const dotenv = require('dotenv')
const migrate = require('../')
const runMigrations = require('../lib/migrate')
const log = require('../lib/log')
const registerCompiler = require('../lib/register-compiler')
const pkg = require('../package.json')

program
.version(pkg.version)
Expand All @@ -30,7 +30,7 @@ process.chdir(program.chdir)

// Setup environment
if (program.env) {
var e = dotenv.config({
const e = dotenv.config({
path: typeof program.env === 'string' ? program.env : '.env'
})
if (e && e.error instanceof Error) {
Expand All @@ -46,8 +46,8 @@ if (program.compiler) {
// Setup store
if (program.store[0] === '.') program.store = path.join(process.cwd(), program.store)

var Store = require(program.store)
var store = new Store(program.stateFile)
const Store = require(program.store)
const store = new Store(program.stateFile)

// Load in migrations
migrate.load({
Expand Down
22 changes: 11 additions & 11 deletions bin/migrate-init
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// vim: set ft=javascript:
'use strict'

var program = require('commander')
var mkdirp = require('mkdirp')
var dotenv = require('dotenv')
var path = require('path')
var log = require('../lib/log')
var pkg = require('../package.json')
var registerCompiler = require('../lib/register-compiler')
const program = require('commander')
const mkdirp = require('mkdirp')
const dotenv = require('dotenv')
const path = require('path')
const log = require('../lib/log')
const pkg = require('../package.json')
const registerCompiler = require('../lib/register-compiler')

program
.version(pkg.version)
Expand All @@ -25,7 +25,7 @@ process.chdir(program.chdir)

// Setup environment
if (program.env) {
var e = dotenv.config({
const e = dotenv.config({
path: typeof program.env === 'string' ? program.env : '.env'
})
if (e && e.error instanceof Error) {
Expand All @@ -41,11 +41,11 @@ if (program.compiler) {
// Setup store
if (program.store[0] === '.') program.store = path.join(process.cwd(), program.store)

var Store = require(program.store)
var store = new Store(program.stateFile)
const Store = require(program.store)
const store = new Store(program.stateFile)

// Create migrations dir path
var p = path.resolve(process.cwd(), program.migrationsDir)
const p = path.resolve(process.cwd(), program.migrationsDir)

log('migrations dir', p)
mkdirp.sync(p)
Expand Down
24 changes: 12 additions & 12 deletions bin/migrate-list
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// vim: set ft=javascript:
'use strict'

var program = require('commander')
var path = require('path')
var dateFormat = require('dateformat')
var minimatch = require('minimatch')
var dotenv = require('dotenv')
var migrate = require('../')
var log = require('../lib/log')
var registerCompiler = require('../lib/register-compiler')
var pkg = require('../package.json')
const program = require('commander')
const path = require('path')
const dateFormat = require('dateformat')
const minimatch = require('minimatch')
const dotenv = require('dotenv')
const migrate = require('../')
const log = require('../lib/log')
const registerCompiler = require('../lib/register-compiler')
const pkg = require('../package.json')

program
.version(pkg.version)
Expand All @@ -36,7 +36,7 @@ process.chdir(program.chdir)

// Setup environment
if (program.env) {
var e = dotenv.config({
const e = dotenv.config({
path: typeof program.env === 'string' ? program.env : '.env'
})
if (e && e.error instanceof Error) {
Expand All @@ -52,8 +52,8 @@ if (program.compiler) {
// Setup store
if (program.store[0] === '.') program.store = path.join(process.cwd(), program.store)

var Store = require(program.store)
var store = new Store(program.stateFile)
const Store = require(program.store)
const store = new Store(program.stateFile)

// Load in migrations
migrate.load({
Expand Down
24 changes: 12 additions & 12 deletions bin/migrate-up
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// vim: set ft=javascript:
'use strict'

var program = require('commander')
var path = require('path')
var minimatch = require('minimatch')
var dotenv = require('dotenv')
var migrate = require('../')
var runMigrations = require('../lib/migrate')
var log = require('../lib/log')
var registerCompiler = require('../lib/register-compiler')
var pkg = require('../package.json')
const program = require('commander')
const path = require('path')
const minimatch = require('minimatch')
const dotenv = require('dotenv')
const migrate = require('../')
const runMigrations = require('../lib/migrate')
const log = require('../lib/log')
const registerCompiler = require('../lib/register-compiler')
const pkg = require('../package.json')

program
.version(pkg.version)
Expand All @@ -32,7 +32,7 @@ process.chdir(program.chdir)

// Setup environment
if (program.env) {
var e = dotenv.config({
const e = dotenv.config({
path: typeof program.env === 'string' ? program.env : '.env'
})
if (e && e.error instanceof Error) {
Expand Down Expand Up @@ -60,8 +60,8 @@ if (program.compiler) {
// Setup store
if (program.store[0] === '.') program.store = path.join(process.cwd(), program.store)

var Store = require(program.store)
var store = new Store(program.stateFile)
const Store = require(program.store)
const store = new Store(program.stateFile)

// Call store init
if (program.init && typeof store.init === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/migrations/1316027432511-add-pets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var db = require('./db')
const db = require('./db')

exports.up = function (next) {
db.rpush('pets', 'tobi')
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/migrations/1316027432512-add-jane.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var db = require('./db')
const db = require('./db')

exports.up = function (next) {
db.rpush('pets', 'jane', next)
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/migrations/1316027432575-add-owners.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var db = require('./db')
const db = require('./db')

exports.up = function (next) {
db.rpush('owners', 'taylor')
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/migrations/1316027433425-coolest-pet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var db = require('./db')
const db = require('./db')

exports.up = function (next) {
db.set('pets:coolest', 'tobi', next)
Expand Down
4 changes: 2 additions & 2 deletions examples/cli/migrations/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// $ npm install redis
// $ redis-server

var redis = require('redis')
var db = redis.createClient()
const redis = require('redis')
const db = redis.createClient()

module.exports = db
2 changes: 2 additions & 0 deletions examples/custom-state-storage/mongo-state-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class MongoDbStore {
return fn(null, {})
}
} catch (err) {
console.log(err)
throw err
} finally {
client.close()
Expand All @@ -39,6 +40,7 @@ class MongoDbStore {
}
}, { upsert: true })
} catch (err) {
console.log(err)
throw err
} finally {
client.close()
Expand Down
4 changes: 2 additions & 2 deletions examples/env/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
var fs = require('fs')
const fs = require('fs')

module.exports = {
loaded: false,
Expand All @@ -25,7 +25,7 @@ module.exports = {
},
load: function () {
if (this.loaded) return this
var json
let json
try {
json = JSON.parse(fs.readFileSync('.db', 'utf8'))
} catch (e) {
Expand Down
10 changes: 5 additions & 5 deletions examples/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// $ npm install redis
// $ redis-server

var path = require('path')
var migrate = require('../')
var redis = require('redis')
var db = redis.createClient()
const path = require('path')
const migrate = require('../')
const redis = require('redis')
const db = redis.createClient()

migrate(path.join(__dirname, '.migrate'))

Expand Down Expand Up @@ -39,7 +39,7 @@ migrate('coolest pet', function (next) {
db.del('pets:coolest', next)
})

var set = migrate()
const set = migrate()

console.log()
set.on('save', function () {
Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* Module dependencies.
*/

var MigrationSet = require('./lib/set')
var FileStore = require('./lib/file-store')
var loadMigrationsIntoSet = require('./lib/load-migrations')
const MigrationSet = require('./lib/set')
const FileStore = require('./lib/file-store')
const loadMigrationsIntoSet = require('./lib/load-migrations')

/**
* Expose the migrate function.
Expand Down Expand Up @@ -42,13 +42,13 @@ function migrate (title, up, down) {
exports.MigrationSet = MigrationSet

exports.load = function (options, fn) {
var opts = options || {}
const opts = options || {}

// Create default store
var store = (typeof opts.stateStore === 'string') ? new FileStore(opts.stateStore) : opts.stateStore
const store = (typeof opts.stateStore === 'string') ? new FileStore(opts.stateStore) : opts.stateStore

// Create migration set
var set = new MigrationSet(store)
const set = new MigrationSet(store)

loadMigrationsIntoSet({
set: set,
Expand Down
7 changes: 4 additions & 3 deletions lib/file-store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

var fs = require('fs')
const fs = require('fs')
const hasOwnProperty = Object.prototype.hasOwnProperty

module.exports = FileStore

Expand Down Expand Up @@ -44,7 +45,7 @@ FileStore.prototype.load = function (fn) {
}

// Check if old format and convert if needed
if (!store.hasOwnProperty('lastRun') && store.hasOwnProperty('pos')) {
if (!hasOwnProperty.call(store, 'lastRun') && hasOwnProperty.call(store, 'pos')) {
if (store.pos === 0) {
store.lastRun = null
} else {
Expand All @@ -64,7 +65,7 @@ FileStore.prototype.load = function (fn) {
}

// Check if does not have required properties
if (!store.hasOwnProperty('lastRun') || !store.hasOwnProperty('migrations')) {
if (!hasOwnProperty.call(store, 'lastRun') || !hasOwnProperty.call(store, 'migrations')) {
return fn(new Error('Invalid store file'))
}

Expand Down
Loading

0 comments on commit c07848d

Please sign in to comment.