johankit 0.1.2 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "johankit",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -2,22 +2,17 @@ import { scanDir } from "../../core/scan";
2
2
  import { copyToClipboard } from "../../core/clipboard";
3
3
 
4
4
  export async function copy(input: string | string[]) {
5
- let snapshot;
5
+ let snapshot: any[] = [];
6
6
 
7
- if (Array.isArray(input)) {
8
- snapshot = input.map(path => {
9
- const fileSnapshot = scanDir(path);
10
- if (fileSnapshot.length !== 1) {
11
- throw new Error(`Expected single file for path: ${path}`);
12
- }
13
- return fileSnapshot[0];
14
- });
15
- } else {
16
- snapshot = scanDir(input);
7
+ const paths = Array.isArray(input) ? input : [input];
8
+
9
+ for (const p of paths) {
10
+ const scanned = scanDir(p);
11
+ snapshot.push(...scanned);
17
12
  }
18
13
 
19
14
  const clipboardJSON = JSON.stringify(snapshot, null, 2);
20
-
15
+
21
16
  try {
22
17
  await copyToClipboard(clipboardJSON);
23
18
  } catch (err) {
@@ -25,4 +20,4 @@ export async function copy(input: string | string[]) {
25
20
  }
26
21
 
27
22
  return clipboardJSON;
28
- }
23
+ }