Skip to content

Commit d02c9b4

Browse files
committed
2.0.2 fixed regex
1 parent ed78ea8 commit d02c9b4

3 files changed

Lines changed: 53 additions & 70 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "docker-cli-js",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A node.js wrapper for the docker-machine CLI",
55
"main": "dist/index.js",
66
"typings": "dist/index",
77
"files": [
8-
"dist/",
9-
"typings.json"
8+
"dist/"
109
],
1110
"scripts": {
1211
"lint": "tslint src/**/*.ts",
1312
"build": "rimraf dist/ && tsc",
1413
"test-spec": "ts-node node_modules/blue-tape/bin/blue-tape.js \"src/**/*.spec.ts\" | tap-diff",
15-
"test": "npm run lint && npm run build && npm run test-spec"
14+
"test": "npm run lint && npm run build && npm run test-spec",
15+
"prepublish": "npm run lint && npm run build && rimraf dist/**/*.spec.* "
1616
},
1717
"repository": {
1818
"type": "git",

src/index.spec.ts

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ test('docker-cli-js', t => {
2222

2323
});
2424

25-
//t.test('info callback', t => {
26-
// let docker = new Docker();
27-
28-
// return docker.command('info', function (err, data) {
29-
// console.log(data);
30-
// t.ok(data);
31-
// t.ok(data.object.server_version);
32-
// });
33-
34-
//});
35-
3625
//t.test('info', t => {
3726
// const options = new Options(
3827
// /* machineName */ 'machinename',
@@ -49,7 +38,7 @@ test('docker-cli-js', t => {
4938

5039
//});
5140

52-
//t.test('build', t => {
41+
t.test('build', t => {
5342

5443
const options = new Options(
5544
/* machineName */ null,
@@ -60,58 +49,60 @@ test('docker-cli-js', t => {
6049

6150
return docker.command('build -t nginximg .').then(function (data) {
6251
console.log('data = ', data);
52+
t.ok(data);
53+
t.ok(data.success);
6354
});
64-
//});
55+
});
6556

6657

67-
//t.test('run', t => {
58+
t.test('run', t => {
6859

69-
// let docker = new Docker();
60+
let docker = new Docker();
7061

71-
// return docker.command('run --name nginxcont -d -p 80:80 nginximg').then(function (data) {
72-
// console.log('data = ', data);
73-
// t.ok(data.containerId);
74-
// });
75-
//});
62+
return docker.command('run --name nginxcont -d -p 80:80 nginximg').then(function (data) {
63+
console.log('data = ', data);
64+
t.ok(data.containerId);
65+
});
66+
});
7667

77-
//t.test('ps', t => {
68+
t.test('ps', t => {
7869

79-
// let docker = new Docker();
70+
let docker = new Docker();
8071

81-
// return docker.command('ps').then(function (data) {
82-
// console.log('data = ', data);
83-
// t.ok(data.containerList);
84-
// });
85-
//});
72+
return docker.command('ps').then(function (data) {
73+
console.log('data = ', data);
74+
t.ok(data.containerList);
75+
});
76+
});
8677

87-
//t.test('images', t => {
78+
t.test('images', t => {
8879

89-
// let docker = new Docker();
80+
let docker = new Docker();
9081

91-
// return docker.command('images').then(function (data) {
92-
// console.log('data = ', data);
93-
// t.ok(data.images);
94-
// });
95-
//});
82+
return docker.command('images').then(function (data) {
83+
console.log('data = ', data);
84+
t.ok(data.images);
85+
});
86+
});
9687

97-
//t.test('network ls', t => {
88+
t.test('network ls', t => {
9889

99-
// let docker = new Docker();
90+
let docker = new Docker();
10091

101-
// return docker.command('network ls').then(function (data) {
102-
// console.log('data = ', data);
103-
// t.ok(data.network);
104-
// });
105-
//});
92+
return docker.command('network ls').then(function (data) {
93+
console.log('data = ', data);
94+
t.ok(data.network);
95+
});
96+
});
10697

107-
//t.test('inspect', t => {
98+
t.test('inspect', t => {
10899

109-
// let docker = new Docker();
100+
let docker = new Docker();
110101

111-
// return docker.command('inspect nginxcont').then(function (data) {
112-
// console.log('data = ', data);
113-
// t.ok(data.object);
114-
// });
115-
//});
102+
return docker.command('inspect nginxcont').then(function (data) {
103+
console.log('data = ', data);
104+
t.ok(data.object);
105+
});
106+
});
116107

117108
});

src/index.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const extractResult = function (result) {
2727

2828
const extracterArray = [
2929
{
30-
re: /build/,
30+
re: / build /,
3131
run: function (resultp) {
3232
const lines = resultp.raw.split(os.EOL);
3333

@@ -53,7 +53,7 @@ const extractResult = function (result) {
5353
},
5454
},
5555
{
56-
re: /run/,
56+
re: / run /,
5757
run: function (resultp) {
5858
resultp.containerId = resultp.raw.trim();
5959

@@ -62,7 +62,7 @@ const extractResult = function (result) {
6262
},
6363
},
6464
{
65-
re: /ps/,
65+
re: / ps /,
6666
run: function (resultp) {
6767
const lines = resultp.raw.split(os.EOL);
6868

@@ -72,7 +72,7 @@ const extractResult = function (result) {
7272
},
7373
},
7474
{
75-
re: /images/,
75+
re: / images /,
7676
run: function (resultp) {
7777
const lines = resultp.raw.split(os.EOL);
7878

@@ -84,7 +84,7 @@ const extractResult = function (result) {
8484
},
8585
},
8686
{
87-
re: /network ls/,
87+
re: / network ls /,
8888
run: function (resultp) {
8989
const lines = resultp.raw.split(os.EOL);
9090

@@ -96,7 +96,7 @@ const extractResult = function (result) {
9696
},
9797
},
9898
{
99-
re: /inspect/,
99+
re: / inspect /,
100100
run: function (resultp) {
101101
const object = JSON.parse(resultp.raw);
102102

@@ -106,7 +106,7 @@ const extractResult = function (result) {
106106
},
107107
},
108108
{
109-
re: /info/,
109+
re: / info /,
110110
run: function (resultp) {
111111
const lines = resultp.raw.split(os.EOL);
112112
resultp.object = array2Oject(lines);
@@ -160,10 +160,7 @@ export class Docker {
160160
});
161161
}
162162
}).then(function () {
163-
return Promise.delay(2000);
164-
}).then(function () {
165-
execCommand += ' ' + machineconfig + ' ' + command;
166-
163+
execCommand += ' ' + machineconfig + ' ' + command + ' ';
167164

168165
let execOptions = {
169166
cwd: docker.options.currentWorkingDirectory,
@@ -175,16 +172,11 @@ export class Docker {
175172
maxBuffer: 200 * 1024 * 1024,
176173
};
177174

178-
179175
return new Promise(function (resolve, reject) {
180176
//console.log('execCommand =', execCommand);
181177
//console.log('exec options =', execOptions);
182178

183-
//setTimeout(function () {
184-
// resolve('test');
185-
//}, 3000);
186-
187-
return exec(execCommand, execOptions, function(error, stdout, stderr) {
179+
exec(execCommand, execOptions, function(error, stdout, stderr) {
188180
if (error) {
189181
//console.error(`exec error: ${error}`);
190182
return reject(stderr);
@@ -194,7 +186,7 @@ export class Docker {
194186
resolve({ result: stdout});
195187
});
196188
});
197-
}).then(function (data: { result: string }) {
189+
}).then(function (data: { result: string }) {
198190
//console.log('data:', data);
199191
let result = {
200192
command: execCommand,

0 commit comments

Comments
 (0)