@netlify/functions-utils 3.0.1 → 4.0.0
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.
- package/package.json +5 -4
- package/src/main.js +9 -13
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/functions-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Utility for adding Functions files in Netlify Build",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": "./src/main.js",
|
|
7
|
+
"main": "./src/main.js",
|
|
6
8
|
"files": [
|
|
7
9
|
"src/**/*.js"
|
|
8
10
|
],
|
|
9
11
|
"author": "Netlify Inc.",
|
|
10
12
|
"scripts": {
|
|
11
|
-
"prepublishOnly": "cd ../../ && npm run prepublishOnly"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"nodejs",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"license": "MIT",
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@netlify/zip-it-and-ship-it": "^5.
|
|
47
|
+
"@netlify/zip-it-and-ship-it": "^5.2.0",
|
|
47
48
|
"cpy": "^8.1.0",
|
|
48
49
|
"path-exists": "^4.0.0"
|
|
49
50
|
},
|
package/src/main.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { stat } from 'fs'
|
|
2
|
+
import { basename, dirname } from 'path'
|
|
3
|
+
import { promisify } from 'util'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 }
|