Skip to content

Commit

Permalink
Clean up uncommitted code and add waitForLine function from Chris
Browse files Browse the repository at this point in the history
  • Loading branch information
strazzere committed Sep 20, 2021
1 parent 7740a80 commit ff1607c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
16 changes: 12 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@corellium/corellium-api",
"version": "1.0.0",
"version": "1.1.1",
"description": "Supported nodejs library for interacting with the Corellium service and VMs",
"main": "src/corellium.js",
"husky": {
Expand All @@ -22,6 +22,7 @@
"jszip": "^3.7.1",
"p-retry": "^2.0.0",
"p-timeout": "^3.2.0",
"split": "^1.0.1",
"uuid": "^3.3.2",
"websocket-stream": "^5.1.1",
"xhr2": "^0.2.0"
Expand Down
21 changes: 21 additions & 0 deletions src/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const util = require("util");
const fs = require("fs");
const { compress, uploadFile } = require("./images");
const uuidv4 = require("uuid/v4");
const split = require("split");

/**
* @typedef {object} ThreadInfo
Expand Down Expand Up @@ -448,6 +449,26 @@ class Instance extends EventEmitter {
return wsstream(url, ["binary"]);
}

/**
* Waits for a specified line on console.
* @example
* await instance.waitForLineOnConsole(line)
*/
async waitForLineOnConsole(line) {
const stream = await this.console();
await stream
.pipe(split())
.on("data", (l) => {
if (l === line) {
stream.destroy();
return;
}
})
.on("end", () => {
return;
});
}

/**
* Returns the cost, in microcents, for the instance in the on and off state. Instances are charged $0.25 / day for storage (off) and $0.25 per core per hour (on).
* @returns {RateInfo}
Expand Down

0 comments on commit ff1607c

Please sign in to comment.