Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

feat: add repositoryRoot property #739

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ Format of the archive created for each function. Defaults to ZIP archives.

If set to `none`, the output of each function will be a directory containing all the bundled files.

#### `basePath`
netlify-team-account-1 marked this conversation as resolved.
Show resolved Hide resolved

- _Type_: `string`
- _Default value_: `undefined`

The directory which all relative paths will be resolved from. These include paths in the `includedFiles` config
property, as well as imports using dynamic expressions such as `require(\`./files/${name}\`)`.

#### `config`

- _Type_: `object`
Expand Down Expand Up @@ -172,6 +180,14 @@ JSON-formatted string with the following properties:

Maximum number of functions to bundle at the same time.

#### `repositoryRoot`

- _Type_: `string`
- _Default value_: The value of `basePath`

The path of the project's repository root. This defines the boundary where Node modules can be found. It usually is the
same value as the `basePath` property, but may be a parent directory in the case of a monorepo setup.

### Return value

This returns a `Promise` resolving to an array of objects describing each archive. Every object has the following
Expand Down
16 changes: 10 additions & 6 deletions src/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const zipFunctions = async function (
featureFlags: inputFeatureFlags,
manifest,
parallelLimit = DEFAULT_PARALLEL_LIMIT,
repositoryRoot = basePath,
} = {},
) {
validateArchiveFormat(archiveFormat)
Expand Down Expand Up @@ -90,6 +91,7 @@ const zipFunctions = async function (
mainFile: func.mainFile,
name: func.name,
pluginsModulesPath,
repositoryRoot,
runtime: func.runtime,
srcDir: func.srcDir,
srcPath: func.srcPath,
Expand Down Expand Up @@ -121,6 +123,7 @@ const zipFunction = async function (
config: inputConfig = {},
featureFlags: inputFeatureFlags,
pluginsModulesPath: defaultModulesPath,
repositoryRoot = basePath,
} = {},
) {
validateArchiveFormat(archiveFormat)
Expand All @@ -143,16 +146,17 @@ const zipFunction = async function (
archiveFormat,
basePath,
config,
srcPath,
destFolder,
mainFile,
filename,
extension,
featureFlags,
filename,
mainFile,
pluginsModulesPath,
repositoryRoot,
netlify-team-account-1 marked this conversation as resolved.
Show resolved Hide resolved
runtime,
srcDir,
srcPath,
stat,
runtime,
pluginsModulesPath,
featureFlags,
})

return formatZipResult({ ...zipResult, mainFile, name, runtime })
Expand Down