mirror of
https://github.com/zhigang1992/firebase-tools.git
synced 2026-01-12 17:22:36 +08:00
Minor fixes to how emulators are downloaded + run
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const FirebaseError = require("../error");
|
||||
const fs = require("fs-extra");
|
||||
const request = require("request");
|
||||
const emulatorConstants = require("./constants");
|
||||
@@ -13,6 +14,11 @@ module.exports = (name) => {
|
||||
let req = request.get(emulator.remoteUrl);
|
||||
let writeStream = fs.createWriteStream(emulator.localPath);
|
||||
req.on("error", (err) => reject(err));
|
||||
req.on('response', response => {
|
||||
if (response.statusCode != 200) {
|
||||
reject(new FirebaseError(`download failed, status ${response.statusCode}`, { exit: 1 }));
|
||||
}
|
||||
});
|
||||
req.on("end", () => {
|
||||
writeStream.close();
|
||||
fs.chmodSync(emulator.localPath, 0o755);
|
||||
|
||||
@@ -23,7 +23,7 @@ function _runBinary(emulator, command) {
|
||||
stdio: ["inherit", "pipe", "pipe"],
|
||||
});
|
||||
emulator.instance.stdout.on("data", (data) => {
|
||||
console.log(data.toString());
|
||||
process.stdout.write(data.toString());
|
||||
emulator.stdout.write(data.toString());
|
||||
});
|
||||
emulator.instance.stderr.on("data", (data) => {
|
||||
@@ -51,7 +51,6 @@ function _runBinary(emulator, command) {
|
||||
utils.logLabeledBullet(emulator.name, "emulator has exited");
|
||||
}
|
||||
});
|
||||
utils.logLabeledSuccess(emulator.name, "started on http://localhost:" + emulator.port);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user