-
Notifications
You must be signed in to change notification settings - Fork 43
Simplify options handling #238
Conversation
const hashFiles = async ( | ||
dir, | ||
configPath, | ||
{ concurrentHash, hashAlgorithm = 'sha1', assetType = 'file', statusCb, filter }, |
There was a problem hiding this comment.
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 }) => { |
There was a problem hiding this comment.
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 }) => { |
There was a problem hiding this comment.
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 }) => |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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).
9e0c704
to
aa0ab56
Compare
fceb6f4
to
76a7ef7
Compare
76a7ef7
to
c422f0e
Compare
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.