New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dockerode-process

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dockerode-process - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

utils_test.js

37

docker_process_test.js

@@ -5,2 +5,31 @@ suite('docker process', function() {

suite('#run - with pull', function() {
var subject;
setup(function() {
subject = new DockerRun(docker, {
create: {
Image: 'ubuntu',
Cmd: ['/bin/bash', '-c', 'echo stdout && echo stderr >&2'],
Tty: true
},
start: {}
});
});
test('single stream with pulling', function() {
var expected = 'stdout\nstderr\n';
var result = '';
subject.stdout.on('data', function(value) {
result += value;
});
return subject.run().then(function() {
result = result.replace(/\r/g, '');
assert.ok(result.indexOf('ubuntu') !== -1, 'mentions docker image');
assert.ok(result.indexOf(expected) !== -1, 'has stdout/stderr');
});
});
});
suite('#run - with tty', function() {

@@ -19,3 +48,3 @@ var subject;

test('single stream from tty', function() {
test('single stream from tty (no pull)', function() {
var expected = 'stdout\nstderr\n';

@@ -28,3 +57,3 @@ var result = '';

return subject.run().then(function() {
return subject.run({ pull: false }).then(function() {
// ensure there are only \n and no \r

@@ -37,3 +66,3 @@ result = result.replace('\r', '');

suite('#run - without tty', function() {
suite('#run - without tty (no pull)', function() {
var subject;

@@ -58,3 +87,3 @@ setup(function() {

var promise = subject.run();
var promise = subject.run({ pull: false });

@@ -61,0 +90,0 @@ assert.ok(subject.stdout, 'has stdout, stream');

var EventEmitter = require('events').EventEmitter;
var streams = require('stream');
var debug = require('debug')('docker-process');
var utils = require('./utils');
var Promise = require('promise');

@@ -65,7 +66,3 @@

/*
/**
Run the docker process and resolve the promise on complete.
*/
run: function() {
_run: function() {
debug('run', this._createConfig, this._startConfig);

@@ -123,2 +120,31 @@

);
},
/**
Run the docker process and resolve the promise on complete.
@param {Object} options for running the container.
@param {Boolean} [options.pull=true] when true pull the image and prepend the
download details to stdout.
*/
run: function(options) {
options = options || {};
if (!('pull' in options)) options.pull = true;
// no pull means no extra stream processing...
if (!options.pull) return this._run();
return new Promise(function(accept, reject) {
// pull the image (or use on in the cache and output status in stdout)
var pullStream = utils.streamImage(this.docker, this._createConfig.Image);
// pipe the pull stream into stdout but don't end
pullStream.pipe(this.stdout, { end: false });
pullStream.once('error', reject);
pullStream.once('end', function() {
pullStream.removeListener('error', reject);
this._run().then(accept, reject);
}.bind(this));
}.bind(this));
}

@@ -125,0 +151,0 @@ };

2

package.json
{
"name": "dockerode-process",
"version": "0.0.1",
"version": "0.1.0",
"description": "ChildProcess like interface for docker containers",

@@ -5,0 +5,0 @@ "main": "docker_process.js",

@@ -49,7 +49,9 @@

### `dockerProc.run()`
### `dockerProc.run([options])`
Create then start the container and return a promise for its exit
status.
Pull the image from the docker index then create then start the container and return a promise for its exit status.
Options:
- (Boolean) `pull=true` when false assume the image is cached.
```js

@@ -56,0 +58,0 @@ dockerProc.run().then(

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc