@netlify/functions-utils 3.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -3
  2. package/src/main.js +9 -13
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@netlify/functions-utils",
3
- "version": "3.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Utility for adding Functions files in Netlify Build",
5
- "main": "src/main.js",
5
+ "type": "module",
6
+ "exports": "./src/main.js",
7
+ "main": "./src/main.js",
6
8
  "files": [
7
9
  "src/**/*.js"
8
10
  ],
@@ -43,7 +45,7 @@
43
45
  },
44
46
  "license": "MIT",
45
47
  "dependencies": {
46
- "@netlify/zip-it-and-ship-it": "^4.30.0",
48
+ "@netlify/zip-it-and-ship-it": "^5.3.1",
47
49
  "cpy": "^8.1.0",
48
50
  "path-exists": "^4.0.0"
49
51
  },
package/src/main.js CHANGED
@@ -1,18 +1,16 @@
1
- 'use strict'
1
+ import { stat } from 'fs'
2
+ import { basename, dirname } from 'path'
3
+ import { promisify } from 'util'
2
4
 
3
- const { stat } = require('fs')
4
- const { basename, dirname } = require('path')
5
- const { promisify } = require('util')
6
-
7
- const { listFunctions, listFunctionsFiles } = require('@netlify/zip-it-and-ship-it')
8
- const cpy = require('cpy')
9
- const pathExists = require('path-exists')
5
+ import { listFunctions, listFunctionsFiles } from '@netlify/zip-it-and-ship-it'
6
+ import cpy from 'cpy'
7
+ import pathExists from 'path-exists'
10
8
 
11
9
  const pStat = promisify(stat)
12
10
 
13
11
  // Add a Netlify Function file to the `functions` directory so it is processed
14
12
  // by `@netlify/plugin-functions-core`
15
- const add = async function (src, dist, { fail = defaultFail } = {}) {
13
+ export const add = async function (src, dist, { fail = defaultFail } = {}) {
16
14
  if (src === undefined) {
17
15
  return fail('No function source directory was specified')
18
16
  }
@@ -40,7 +38,7 @@ const getSrcGlob = async function (src, srcBasename) {
40
38
  return srcBasename
41
39
  }
42
40
 
43
- const list = async function (functionsSrc, { fail = defaultFail } = {}) {
41
+ export const list = async function (functionsSrc, { fail = defaultFail } = {}) {
44
42
  if (functionsSrc === undefined || functionsSrc.length === 0) {
45
43
  return fail('No function directory was specified')
46
44
  }
@@ -52,7 +50,7 @@ const list = async function (functionsSrc, { fail = defaultFail } = {}) {
52
50
  }
53
51
  }
54
52
 
55
- const listAll = async function (functionsSrc, { fail = defaultFail } = {}) {
53
+ export const listAll = async function (functionsSrc, { fail = defaultFail } = {}) {
56
54
  if (functionsSrc === undefined || functionsSrc.length === 0) {
57
55
  return fail('No function directory was specified')
58
56
  }
@@ -67,5 +65,3 @@ const listAll = async function (functionsSrc, { fail = defaultFail } = {}) {
67
65
  const defaultFail = function (message) {
68
66
  throw new Error(message)
69
67
  }
70
-
71
- module.exports = { add, list, listAll }