@netlify/functions-utils 2.0.0 → 3.0.1
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 -5
- package/src/main.js +4 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/functions-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Utility for adding Functions files in Netlify Build",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"files": [
|
|
@@ -43,18 +43,18 @@
|
|
|
43
43
|
},
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@netlify/zip-it-and-ship-it": "^
|
|
46
|
+
"@netlify/zip-it-and-ship-it": "^5.0.0",
|
|
47
47
|
"cpy": "^8.1.0",
|
|
48
48
|
"path-exists": "^4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"ava": "^
|
|
51
|
+
"ava": "^3.15.0",
|
|
52
52
|
"del": "^5.1.0",
|
|
53
|
-
"sinon": "^
|
|
53
|
+
"sinon": "^12.0.0",
|
|
54
54
|
"sort-on": "^4.1.0",
|
|
55
55
|
"tmp-promise": "^3.0.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
58
|
+
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/main.js
CHANGED
|
@@ -4,6 +4,7 @@ const { stat } = require('fs')
|
|
|
4
4
|
const { basename, dirname } = require('path')
|
|
5
5
|
const { promisify } = require('util')
|
|
6
6
|
|
|
7
|
+
const { listFunctions, listFunctionsFiles } = require('@netlify/zip-it-and-ship-it')
|
|
7
8
|
const cpy = require('cpy')
|
|
8
9
|
const pathExists = require('path-exists')
|
|
9
10
|
|
|
@@ -25,13 +26,8 @@ const add = async function (src, dist, { fail = defaultFail } = {}) {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const srcBasename = basename(src)
|
|
28
|
-
const functionsDist = `${dist}/${srcBasename}`
|
|
29
|
-
if (await pathExists(functionsDist)) {
|
|
30
|
-
return fail(`Function file or directory already exists at "${functionsDist}"`)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
const srcGlob = await getSrcGlob(src, srcBasename)
|
|
34
|
-
await cpy(srcGlob, dist, { cwd: dirname(src), parents: true, overwrite:
|
|
30
|
+
await cpy(srcGlob, dist, { cwd: dirname(src), parents: true, overwrite: true })
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
const getSrcGlob = async function (src, srcBasename) {
|
|
@@ -45,15 +41,10 @@ const getSrcGlob = async function (src, srcBasename) {
|
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
const list = async function (functionsSrc, { fail = defaultFail } = {}) {
|
|
48
|
-
if (functionsSrc === undefined) {
|
|
44
|
+
if (functionsSrc === undefined || functionsSrc.length === 0) {
|
|
49
45
|
return fail('No function directory was specified')
|
|
50
46
|
}
|
|
51
47
|
|
|
52
|
-
// This package currently supports Node 8 but not zip-it-and-ship-it
|
|
53
|
-
// @todo put the `require()` to the top-level scope again once Node 8 support
|
|
54
|
-
// is removed
|
|
55
|
-
// eslint-disable-next-line node/global-require
|
|
56
|
-
const { listFunctions } = require('@netlify/zip-it-and-ship-it')
|
|
57
48
|
try {
|
|
58
49
|
return await listFunctions(functionsSrc)
|
|
59
50
|
} catch (error) {
|
|
@@ -62,15 +53,10 @@ const list = async function (functionsSrc, { fail = defaultFail } = {}) {
|
|
|
62
53
|
}
|
|
63
54
|
|
|
64
55
|
const listAll = async function (functionsSrc, { fail = defaultFail } = {}) {
|
|
65
|
-
if (functionsSrc === undefined) {
|
|
56
|
+
if (functionsSrc === undefined || functionsSrc.length === 0) {
|
|
66
57
|
return fail('No function directory was specified')
|
|
67
58
|
}
|
|
68
59
|
|
|
69
|
-
// This package currently supports Node 8 but not zip-it-and-ship-it
|
|
70
|
-
// @todo put the `require()` to the top-level scope again once Node 8 support
|
|
71
|
-
// is removed
|
|
72
|
-
// eslint-disable-next-line node/global-require
|
|
73
|
-
const { listFunctionsFiles } = require('@netlify/zip-it-and-ship-it')
|
|
74
60
|
try {
|
|
75
61
|
return await listFunctionsFiles(functionsSrc)
|
|
76
62
|
} catch (error) {
|