Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove usage of async module #702

Merged
merged 5 commits into from
May 9, 2019

Conversation

AVaksman
Copy link
Contributor

@AVaksman AVaksman commented May 7, 2019

Towards googleapis/google-cloud-node/issues/2883

  • Tests and linter pass

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 7, 2019
@codecov
Copy link

codecov bot commented May 7, 2019

Codecov Report

Merging #702 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #702   +/-   ##
=======================================
  Coverage   96.77%   96.77%           
=======================================
  Files           9        9           
  Lines        1149     1149           
  Branches      294      294           
=======================================
  Hits         1112     1112           
  Misses          9        9           
  Partials       28       28
Impacted Files Coverage Δ
src/bucket.ts 92.89% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 42937a8...ca17cde. Read the comment docs.

@AVaksman AVaksman marked this pull request as ready for review May 7, 2019 18:47
Copy link
Contributor

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a huge improvement. Thank you!

import * as crypto from 'crypto';
import * as fs from 'fs';
import fetch from 'node-fetch';
const normalizeNewline = require('normalize-newline');
const pLimit = require('p-limit');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const pLimit = require('p-limit');
import pLimit = require('p-limit');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks

import * as crypto from 'crypto';
import * as fs from 'fs';
import fetch from 'node-fetch';
const normalizeNewline = require('normalize-newline');
const pLimit = require('p-limit');
const {promisify} = require('util');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const {promisify} = require('util');
import {promisify} from 'util';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as well, thanks

}),
done
after(async () => {
Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the await

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added await, thanks

age: 30,
isLive: true,
},
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird formatting - would expect a semicolon here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, fixed it

}
);
await bucket.lock(bucket.metadata.metageneration);
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an assert.rejects here so we're 100% sure the exception was thrown

Copy link
Contributor Author

@AVaksman AVaksman May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

);
return Promise.all(
FILES.map(file =>
file.setMetadata({temporaryHold: null}).then(() => file.delete())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mix of promises and async/await is weird. Can we just use an async function here and awaits?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed that, thanks

});
const [file] = await bucket.upload(FILES.logo.path, opts);
const [copiedFile] = await file!.copy('CloudLogoCopy');
await Promise.all([file!.delete, copiedFile!.delete()]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be file.delete()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should, fixed, thanks

@AVaksman
Copy link
Contributor Author

AVaksman commented May 8, 2019

This is such a huge improvement. Thank you!

Thank you.

@AVaksman
Copy link
Contributor Author

AVaksman commented May 8, 2019

@JustinBeckwith PTAL

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me, if @JustinBeckwith has already given his 👍 I say ship it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants