@netlify/functions-utils
Utility for adding Functions files in Netlify Build
Last updated 4 days ago by ehmicky .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @netlify/functions-utils 
SYNC missed versions from official npm registry.

Coverage Status Build

Utility for handling Netlify Functions in Netlify Build plugins.

This allows plugins to:

  • list available Netlify Functions
  • dynamically inject Netlify Functions inside users builds.

Example

module.exports = {
  // Add a Netlify Functions file or directory to a build
  async onPreBuild({ utils }) {
    await utils.functions.add('./path/to/function')
  },
}

API

list()

Returns: Promise<object[]>

Returns the list of Netlify Functions main files as a Promise resolving to an array of objects with the following properties:

  • mainFile {string}: absolute path to the Function's main file
  • extension {string}: file extension of the Function's main file. For Go Functions, this might be an empty string. For Node.js Functions, this is either .js or .zip.
  • runtime "js" | "go": Function's programming language

This throws when no functions directory was specified by the user, or when it points to a non-existing directory.

listAll()

Returns: Promise<object[]>

Same as list() except it also returns the files required by the Functions main files. This is much slower. The object have the following additional member:

  • srcFile {string}: absolute path to the file

add(path)

path: string
Returns: Promise

Add a Functions file or directory to a build.

This throws when no functions directory was specified by the user, or when it points to a non-existing directory.

Current Tags

  • 1.2.6                                ...           latest (4 days ago)

18 Versions

  • 1.2.6                                ...           4 days ago
  • 1.2.5                                ...           5 days ago
  • 1.2.4                                ...           9 days ago
  • 1.2.3                                ...           12 days ago
  • 1.2.2                                ...           18 days ago
  • 1.2.1                                ...           18 days ago
  • 1.2.0                                ...           2 months ago
  • 1.1.2                                ...           2 months ago
  • 1.1.1                                ...           2 months ago
  • 1.1.0                                ...           2 months ago
  • 1.0.0                                ...           2 months ago
  • 0.3.0                                ...           2 months ago
  • 0.2.4                                ...           4 months ago
  • 0.2.3                                ...           4 months ago
  • 0.2.2                                ...           4 months ago
  • 0.2.1                                ...           5 months ago
  • 0.2.0                                ...           5 months ago
  • 0.1.0                                ...           7 months ago
Downloads
Today 0
This Week 135
This Month 159
Last Day 7
Last Week 129
Last Month 329
Dependencies (3)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |