@netlify/functions-utils 7.1.4 → 7.1.5

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/lib/main.js +11 -14
  2. package/package.json +4 -7
package/lib/main.js CHANGED
@@ -1,30 +1,27 @@
1
1
  import { promises as fs } from 'fs';
2
- import { basename, dirname, join } from 'path';
2
+ import { basename, join } from 'path';
3
3
  import { listFunctions, listFunctionsFiles } from '@netlify/zip-it-and-ship-it';
4
- import cpy from 'cpy';
5
- import { pathExists } from 'path-exists';
4
+ import { isNotJunk } from 'junk';
6
5
  // Add a Netlify Function file to the `functions` directory, so it is processed
7
6
  // by `@netlify/plugin-functions-core`
8
7
  export const add = async function (src, dist, { fail = defaultFail } = {}) {
9
8
  if (src === undefined) {
10
9
  return fail('No function source directory was specified');
11
10
  }
12
- if (!(await pathExists(src))) {
11
+ try {
12
+ await fs.access(src);
13
+ }
14
+ catch {
13
15
  return fail(`No function file or directory found at "${src}"`);
14
16
  }
15
17
  if (dist === undefined) {
16
18
  return fail('No function directory was specified');
17
19
  }
18
- const srcBasename = basename(src);
19
- const [srcGlob, dest] = await getSrcAndDest(src, srcBasename, dist);
20
- await cpy(srcGlob, dest, { cwd: dirname(src), overwrite: true });
21
- };
22
- const getSrcAndDest = async function (src, srcBasename, dist) {
23
- const srcStat = await fs.stat(src);
24
- if (srcStat.isDirectory()) {
25
- return [`${srcBasename}/**`, join(dist, srcBasename)];
26
- }
27
- return [srcBasename, dist];
20
+ await fs.cp(src, join(dist, basename(src)), {
21
+ recursive: true,
22
+ force: true,
23
+ filter: (source) => isNotJunk(basename(source)),
24
+ });
28
25
  };
29
26
  export const list = async function (functionsSrc, { fail = defaultFail } = {}) {
30
27
  if (functionsSrc === undefined || functionsSrc.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/functions-utils",
3
- "version": "7.1.4",
3
+ "version": "7.1.5",
4
4
  "description": "Utility for adding Functions files in Netlify Build",
5
5
  "type": "module",
6
6
  "exports": "./lib/main.js",
@@ -50,18 +50,15 @@
50
50
  },
51
51
  "license": "MIT",
52
52
  "dependencies": {
53
- "@netlify/zip-it-and-ship-it": "15.3.4",
54
- "cpy": "^11.0.0",
55
- "path-exists": "^5.0.0"
53
+ "@netlify/zip-it-and-ship-it": "15.4.0",
54
+ "junk": "^4.0.0"
56
55
  },
57
56
  "devDependencies": {
58
57
  "@types/node": "^22.12.0",
59
- "sort-on": "^6.0.0",
60
- "tmp-promise": "^3.0.0",
61
58
  "vitest": "^3.0.0"
62
59
  },
63
60
  "engines": {
64
61
  "node": ">=22.12.0"
65
62
  },
66
- "gitHead": "584d4952868504a07a5741b8c37fbef6b10b61b2"
63
+ "gitHead": "aaee524cfed2fc082e6cb7268ce7230071b39068"
67
64
  }