Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ var run = function(image, opts) {
if (opts.entrypoint) copts.Entrypoint = [].concat(opts.entrypoint)

if (opts.ports) {
Object.keys(opts.ports).forEach(function(host) {
var container = opts.ports[host]
Object.keys(opts.ports).forEach(function(container) {
var host = opts.ports[container]
if (!/\//.test(container)) container += '/tcp'
copts.ExposedPorts[container] = {}
sopts.PortBindings[container] = [{HostPort:host+''}]
Expand All @@ -59,9 +59,9 @@ var run = function(image, opts) {
}

if (opts.volumes) {
Object.keys(opts.volumes).forEach(function(host) {
var container = opts.volumes[host]
copts.Volumes[host] = {}
Object.keys(opts.volumes).forEach(function(container) {
var host = opts.volumes[container]
copts.Volumes[container] = {}

if(!endsWith(container, ':rw') || !endsWith(container, ':ro')) container += ':rw'

Expand Down
34 changes: 33 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var tape = require('tape')
var concat = require('concat-stream')
var run = require('./')

var fs = require('fs')
var path = require('path')

tape('spawn bash', function(t) {
var child = run('mafintosh/dev')

Expand All @@ -12,6 +15,35 @@ tape('spawn bash', function(t) {
}))
})

tape('env', function(t) {
var child = run('mafintosh/dev', {
env:{
'ENV_TEST_VAR':'hello world'
}
})

child.stdin.end('echo $ENV_TEST_VAR')
child.stdout.pipe(concat(function(data) {
t.same(data.toString(), 'hello world\n', 'echoes $ENV_TEST_VAR')
t.end()
}))
})

tape('volume', function(t) {
var child = run('mafintosh/dev', {
volumes:{
'/test':__dirname
}
})

var licenceContent = fs.readFileSync(path.join(__dirname, 'LICENSE'), 'utf8')
child.stdin.end('cat /test/LICENSE')
child.stdout.pipe(concat(function(data) {
t.same(data.toString(), licenceContent, 'echoes license file through volume')
t.end()
}))
})

tape('destroy', function(t) {
var child = run('mafintosh/dev')

Expand All @@ -20,4 +52,4 @@ tape('destroy', function(t) {
t.ok(code !== 0, 'not ok exit')
t.end()
})
})
})