rehype-og-card 0.3.2 → 0.3.3

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.
@@ -7,32 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { checkFileExists } from "./file.js";
11
- import fs from "fs/promises";
12
- import path from "path";
13
- /**
14
- * Copy directory from source to destination.
15
- * @param source Source directory.
16
- * @param destination Destination directory.
17
- */
18
- // eslint-disable-next-line max-statements
19
- const copyDirectory = (source, destination) => __awaiter(void 0, void 0, void 0, function* () {
20
- const sourceExists = yield checkFileExists(source);
21
- if (!sourceExists)
22
- return;
23
- const destinationExists = yield checkFileExists(destination);
24
- if (!destinationExists) {
25
- yield fs.mkdir(destination, { recursive: true });
26
- }
27
- const files = yield fs.readdir(source);
28
- const promises = [];
29
- for (const file of files) {
30
- const sourceFile = path.join(source, file);
31
- const destFile = path.join(destination, file);
32
- promises.push(fs.copyFile(sourceFile, destFile));
33
- }
34
- yield Promise.all(promises);
35
- });
10
+ import { copyDirectory } from "./file.js";
36
11
  /**
37
12
  * Save build cache if server cache exists.
38
13
  * @param serverCachePath Server cache path.
@@ -4,4 +4,10 @@
4
4
  * @returns `true` if the file exists, `false` otherwise.
5
5
  */
6
6
  declare const checkFileExists: (filePath: string) => Promise<boolean>;
7
- export { checkFileExists };
7
+ /**
8
+ * Copy directory from source to destination.
9
+ * @param source Source directory.
10
+ * @param destination Destination directory.
11
+ */
12
+ declare const copyDirectory: (source: string, destination: string) => Promise<void>;
13
+ export { checkFileExists, copyDirectory };
package/dist/util/file.js CHANGED
@@ -22,4 +22,19 @@ const checkFileExists = (filePath) => __awaiter(void 0, void 0, void 0, function
22
22
  return false;
23
23
  }
24
24
  });
25
- export { checkFileExists };
25
+ /**
26
+ * Copy directory from source to destination.
27
+ * @param source Source directory.
28
+ * @param destination Destination directory.
29
+ */
30
+ const copyDirectory = (source, destination) => __awaiter(void 0, void 0, void 0, function* () {
31
+ const sourceExists = yield checkFileExists(source);
32
+ if (!sourceExists)
33
+ return;
34
+ const destinationExists = yield checkFileExists(destination);
35
+ if (!destinationExists) {
36
+ yield fs.mkdir(destination, { recursive: true });
37
+ }
38
+ yield fs.cp(source, destination, { recursive: true });
39
+ });
40
+ export { checkFileExists, copyDirectory };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rehype-og-card",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Rehype plugin to convert text links to link cards",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",