Skip to content

Commit

Permalink
async/await and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed Jul 17, 2019
1 parent 910c3df commit 1ab882e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.txt
@@ -1 +1,2 @@
* Fixes issue deploying scheduled functions for non `us-central` project locations.
* Cleans up unnecessary emulator JAR files when a new one is downloaded.
22 changes: 9 additions & 13 deletions src/emulator/download.ts
Expand Up @@ -14,23 +14,19 @@ tmp.setGracefulCleanup();

type DownloadableEmulator = Emulators.FIRESTORE | Emulators.DATABASE;

module.exports = (name: DownloadableEmulator) => {
module.exports = async (name: DownloadableEmulator) => {
const emulator = javaEmulators.get(name);
utils.logLabeledBullet(name, `downloading ${path.basename(emulator.localPath)}...`);
fs.ensureDirSync(emulator.cacheDir);

return downloadToTmp(emulator.remoteUrl)
.then((tmpfile) =>
validateSize(tmpfile, emulator.expectedSize)
.then(() => validateChecksum(tmpfile, emulator.expectedChecksum))
.then(() => {
fs.copySync(tmpfile, emulator.localPath);
fs.chmodSync(emulator.localPath, 0o755);
})
)
.then(() => {
removeOldJars(emulator);
});
const tmpfile = await downloadToTmp(emulator.remoteUrl);
await validateSize(tmpfile, emulator.expectedSize);
await validateChecksum(tmpfile, emulator.expectedChecksum);

fs.copySync(tmpfile, emulator.localPath);
fs.chmodSync(emulator.localPath, 0o755);

await removeOldJars(emulator);
};

function removeOldJars(emulator: JavaEmulatorDetails): void {
Expand Down

0 comments on commit 1ab882e

Please sign in to comment.