Skip to content

Commit

Permalink
Commands now met their own dependecies
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Dec 27, 2015
1 parent bf46e3c commit 65cb2ad
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "adonisjs",
"license": "MIT",
"devDependencies": {
"adonis-fold": "^1.0.0",
"adonis-fold": "file:///Users/harmindervirk/workspace/v2Launch/fold",
"chai": "^3.2.0",
"co": "^4.6.0",
"coveralls": "^2.11.4",
Expand All @@ -26,7 +26,7 @@
"standard": "^5.4.1"
},
"peerDependencies": {
"adonis-fold": "^1.0.0"
"adonis-fold": "file:///Users/harmindervirk/workspace/v2Launch/fold"
},
"dependencies": {
"auto-loader": "^0.2.0",
Expand Down
5 changes: 3 additions & 2 deletions src/Commands/Make.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ module.exports = NewSchema
`

const fs = require('fs')
const Ioc = require('adonis-fold').Ioc

class Make {

constructor (Helpers) {
this.helpers = Helpers
constructor () {
this.helpers = Ioc.make('Adonis/Src/Helpers')
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/Rollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/

const autoLoader = require('auto-loader')
const Ioc = require('adonis-fold').Ioc

class Rollback {

constructor (Helpers, Runner) {
constructor () {
const Helpers = Ioc.make('Adonis/Src/Helpers')
const Runner = Ioc.make('Adonis/Src/Runner')
this.migrations = Helpers.migrationsPath()
this.runner = Runner
}
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/Run.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/

const autoLoader = require('auto-loader')
const Ioc = require('adonis-fold').Ioc

class Run {

constructor (Helpers, Runner) {
constructor () {
const Helpers = Ioc.make('Adonis/Src/Helpers')
const Runner = Ioc.make('Adonis/Src/Runner')
this.migrations = Helpers.migrationsPath()
this.runner = Runner
}
Expand Down
Binary file modified test/implementation/storage/blog.sqlite3
Binary file not shown.
27 changes: 21 additions & 6 deletions test/unit/commands.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

const Make = require('../../src/Commands/Make')
const Run = require('../../src/Commands/Run')
const Ioc = require('adonis-fold').Ioc
const Rollback = require('../../src/Commands/Rollback')
const chai = require('chai')
const path = require('path')
Expand All @@ -28,7 +29,9 @@ const Helpers = {
}
}
}

Ioc.bind('Adonis/Src/Helpers', function () {
return Helpers
})
describe('Commands', function () {
before(function (done) {
GLOBAL.use = function () {
Expand All @@ -45,7 +48,7 @@ describe('Commands', function () {

context('Make', function () {
it('should create a file inside migrations directory', function (done) {
const make = new Make(Helpers)
const make = new Make()
make.description()
make.signature()

Expand All @@ -70,7 +73,10 @@ describe('Commands', function () {
const Runner = {
up: function * (files) {}
}
const run = new Run(Helpers, Runner)
Ioc.bind('Adonis/Src/Runner', function () {
return Runner
})
const run = new Run()

co(function * () {
return yield run.handle({}, {})
Expand All @@ -90,7 +96,10 @@ describe('Commands', function () {
migrations = files
}
}
const run = new Run(Helpers, Runner)
Ioc.bind('Adonis/Src/Runner', function () {
return Runner
})
const run = new Run()
run.description()
run.signature()

Expand All @@ -112,7 +121,10 @@ describe('Commands', function () {
const Runner = {
up: function * (files) {}
}
const rollback = new Rollback(Helpers, Runner)
Ioc.bind('Adonis/Src/Runner', function () {
return Runner
})
const rollback = new Rollback()

co(function * () {
return yield rollback.handle({}, {})
Expand All @@ -132,7 +144,10 @@ describe('Commands', function () {
migrations = files
}
}
const rollback = new Rollback(Helpers, Runner)
Ioc.bind('Adonis/Src/Runner', function () {
return Runner
})
const rollback = new Rollback()
rollback.description()
rollback.signature()

Expand Down
16 changes: 0 additions & 16 deletions test/unit/migrations/1451215262191_create_users_table.js

This file was deleted.

Binary file modified test/unit/storage/schema.sqlite3
Binary file not shown.
Binary file modified test/unit/storage/test.sqlite3
Binary file not shown.

0 comments on commit 65cb2ad

Please sign in to comment.