Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Conversation

ehmicky
Copy link
Contributor

@ehmicky ehmicky commented Dec 15, 2020

This PR simplifies options handling and makes the options available to each method more explicit.
It should not change behavior, but since this is a big refactoring, we should probably wait to release this after the holidays.

@ehmicky ehmicky added the type: chore work needed to keep the product and development running smoothly label Dec 15, 2020
@ehmicky ehmicky requested a review from erezrokah December 15, 2020 20:04
@ehmicky ehmicky self-assigned this Dec 15, 2020
const hashFiles = async (
dir,
configPath,
{ concurrentHash, hashAlgorithm = 'sha1', assetType = 'file', statusCb, filter },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

concurrentHash and statusCb default values are assigned by the calling function.

statusCb: () => {},
...opts,
}
const hashFns = async (dir, { tmpDir, concurrentHash, hashAlgorithm = 'sha256', assetType = 'function', statusCb }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

concurrentHash and statusCb default values are assigned by the calling function.


// a parallel transform stream segment ctor that hashes fileObj's created by folder-walker
const hasherCtor = ({ concurrentHash, hashAlgorithm = 'sha1' }) => {
const hasherCtor = ({ concurrentHash, hashAlgorithm }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hashAlgorithm default value is assigned by the calling function.


// Inject normalized file names into normalizedPath and assetType
const fileNormalizerCtor = ({ assetType = 'file' }) =>
const fileNormalizerCtor = ({ assetType }) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

assetType default value is assigned by the calling function.

if (!statusCb || !assetType) throw new Error('Missing required options')
return objWriter((fileObj, _, cb) => {
// eslint-disable-next-line no-param-reassign
filesObj[fileObj.normalizedPath] = fileObj.hash
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally, we might want to return a copy, but in order to prevent any breaking, this keeps the fact that this function mutates arguments passed by its caller.


const { fnDir, configPath, statusCb, message: title } = opts

deployId: deployIdOpt = null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Distinguish between opts.deploy (passed by user) and deploy.id (returned by API).

@ehmicky ehmicky force-pushed the chore/improve-opts branch 2 times, most recently from fceb6f4 to 76a7ef7 Compare December 16, 2020 18:36
@ehmicky ehmicky merged commit 1540b37 into master Dec 18, 2020
@ehmicky ehmicky deleted the chore/improve-opts branch December 18, 2020 16:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type: chore work needed to keep the product and development running smoothly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants