gce-output-stream
Advanced tools
Comparing version
@@ -33,2 +33,8 @@ 'use strict' | ||
retryRequest(reqOpts, function (err, resp, body) { | ||
if (body.error && body.error.errors && body.error.errors[0]) { | ||
var error = body.error.errors[0] | ||
err = new Error(error.message) | ||
err.response = resp.toJSON() | ||
} | ||
if (err) return outputStream.destroy(err) | ||
@@ -35,0 +41,0 @@ |
{ | ||
"name": "gce-output-stream", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Get a stream of output from a Google Compute Engine instance", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# gce-output-stream | ||
# gce-output-stream [](https://travis-ci.org/stephenplusplus/gce-output-stream) | ||
> Get a stream of output from a Google Compute Engine instance | ||
@@ -11,9 +11,9 @@ | ||
outputStream({ | ||
projectId: 'grape-spaceship-123', | ||
zone: 'us-central1-a', | ||
name: 'app-http-server' | ||
}) | ||
.on('data', function (line) { | ||
// one line of output | ||
}) | ||
projectId: 'grape-spaceship-123', | ||
zone: 'us-central1-a', | ||
name: 'app-http-server' | ||
}) | ||
.on('data', function (line) { | ||
// `line` is a single line of output | ||
}) | ||
``` | ||
@@ -27,3 +27,7 @@ | ||
```js | ||
outputStream({ keyFile: 'key.json' }) | ||
outputStream({ | ||
authConfig: { | ||
keyFile: 'key.json' | ||
} | ||
}) | ||
``` | ||
@@ -30,0 +34,0 @@ |
17
test.js
@@ -41,3 +41,3 @@ 'use strict' | ||
it('should get the output as a stream', function (done) { | ||
this.timeout(0) | ||
this.timeout(10000) | ||
@@ -57,1 +57,16 @@ outputStream({ | ||
}) | ||
it('should return an error from the API response', function (done) { | ||
this.timeout(10000) | ||
outputStream({ | ||
zone: 'us-central1-a', | ||
name: 'instance-name-that-doesnt-exist', | ||
projectId: 'nth-circlet-705', | ||
authConfig: { credentials: require('./key.json') } | ||
}) | ||
.on('error', function (err) { | ||
assert.strictEqual(err.response.statusCode, 404) | ||
done() | ||
}) | ||
}) |
8708
9.42%109
19.78%86
4.88%