stdin-glob 1.0.5 → 1.0.7
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/.github/workflows/npm-publish.yml +0 -1
- package/README.md +35 -6
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -2
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ This pipes all relevant TypeScript/TSX files directly into my clipboard, ready t
|
|
|
25
25
|
|
|
26
26
|
- Expand glob patterns to find matching files
|
|
27
27
|
- Output file contents with syntax highlighting markers
|
|
28
|
+
- Copy output directly to clipboard with `--copy` flag
|
|
28
29
|
- Support for absolute or relative paths
|
|
29
30
|
- Option to show only file paths without content
|
|
30
31
|
- Written in TypeScript
|
|
@@ -43,12 +44,13 @@ stdin-glob [options] [patterns...]
|
|
|
43
44
|
|
|
44
45
|
### Options
|
|
45
46
|
|
|
46
|
-
| Option | Description
|
|
47
|
-
| --------------- |
|
|
48
|
-
| `--no-content` | Do not show file contents, only list matching paths
|
|
49
|
-
| `--absolute` | Show absolute paths for entries
|
|
50
|
-
| `-
|
|
51
|
-
| `-
|
|
47
|
+
| Option | Description |
|
|
48
|
+
| --------------- | ----------------------------------------------------------- |
|
|
49
|
+
| `--no-content` | Do not show file contents, only list matching paths |
|
|
50
|
+
| `--absolute` | Show absolute paths for entries |
|
|
51
|
+
| `-c, --copy` | Copy the output to clipboard instead of printing to console |
|
|
52
|
+
| `-V, --version` | Output the version number |
|
|
53
|
+
| `-h, --help` | Display help information |
|
|
52
54
|
|
|
53
55
|
### Arguments
|
|
54
56
|
|
|
@@ -90,6 +92,22 @@ function add(a, b) {
|
|
|
90
92
|
```
|
|
91
93
|
````
|
|
92
94
|
|
|
95
|
+
### Copy to clipboard
|
|
96
|
+
|
|
97
|
+
Copy all TypeScript file contents directly to clipboard:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
stdin-glob "src/**/*.ts" --copy
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This will copy the formatted output to your clipboard without printing to console. You'll see a confirmation message:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
-> Output copied to clipboard successfully!
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Now you can paste (Ctrl+V or Cmd+V) anywhere - perfect for sharing code in pull requests, documentation, or with LLMs.
|
|
110
|
+
|
|
93
111
|
### Only list files
|
|
94
112
|
|
|
95
113
|
List all TypeScript files in the src directory without content:
|
|
@@ -137,3 +155,14 @@ Use with grep to search for specific content:
|
|
|
137
155
|
```bash
|
|
138
156
|
stdin-glob "src/**/*.ts" | grep "function"
|
|
139
157
|
```
|
|
158
|
+
|
|
159
|
+
Or combine with other clipboard tools for maximum flexibility:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Copy without the confirmation message
|
|
163
|
+
stdin-glob "src/**/*.ts" --no-content | pbcopy
|
|
164
|
+
|
|
165
|
+
# Preview first, then copy if it looks good
|
|
166
|
+
stdin-glob "src/**/*.ts" --content
|
|
167
|
+
stdin-glob "src/**/*.ts" --copy
|
|
168
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -57,6 +57,15 @@ program
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
program.parse(process.argv);
|
|
60
|
+
/**
|
|
61
|
+
* Find the maximum number of consecutive backticks in a string
|
|
62
|
+
*/
|
|
63
|
+
const findMaxConsecutiveBackticks = (str) => {
|
|
64
|
+
const matches = str.match(/`+/g);
|
|
65
|
+
if (!matches)
|
|
66
|
+
return 0;
|
|
67
|
+
return Math.max(...matches.map((m) => m.length));
|
|
68
|
+
};
|
|
60
69
|
/**
|
|
61
70
|
* Get file content with markdown format
|
|
62
71
|
*/
|
|
@@ -64,13 +73,16 @@ const getFileContent = async (filePath) => {
|
|
|
64
73
|
try {
|
|
65
74
|
const content = await (0, promises_1.readFile)(filePath, 'utf-8');
|
|
66
75
|
const extension = path_1.default.extname(filePath).replace('.', '');
|
|
67
|
-
|
|
76
|
+
const maxBackticks = findMaxConsecutiveBackticks(content);
|
|
77
|
+
const wrapper = '`'.repeat(Math.max(3, maxBackticks + 1));
|
|
78
|
+
return (wrapper +
|
|
68
79
|
extension +
|
|
69
80
|
'\n' +
|
|
70
81
|
`// ${filePath}\n\n` +
|
|
71
82
|
content +
|
|
72
83
|
'\n' +
|
|
73
|
-
|
|
84
|
+
wrapper +
|
|
85
|
+
'\n\n');
|
|
74
86
|
}
|
|
75
87
|
catch (e) {
|
|
76
88
|
console.error(`Error reading file ${filePath}:`, e);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,yCAAoC;AACpC,kDAA0C;AAC1C,0CAAuC;AACvC,0DAA6B;AAC7B,gDAAwB;AACxB,4DAAmC;AAQnC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,yDAAyD,CAAC;KACtE,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,cAAc,EAAE,qDAAqD,CAAC;KAC7E,MAAM,CAAC,YAAY,EAAE,oCAAoC,CAAC;KAC1D,MAAM,CACL,YAAY,EACZ,6DAA6D,CAC9D;KACA,QAAQ,CAAC,eAAe,EAAE,8BAA8B,CAAC;KACzD,MAAM,CAAC,KAAK,EAAE,QAAkB,EAAE,OAAgB,EAAE,EAAE;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,aAAa;IACb,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAI,EAAC,QAAQ,EAAE;QACjC,SAAS,EAAE,IAAI;QACf,QA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AM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC;QAE1D,OAAO,CACL,OAAO;YACP,SAAS;YACT,IAAI;YACJ,MAAM,QAAQ,MAAM;YACpB,OAAO;YACP,IAAI;YACJ,OAAO;YACP,MAAM,CACP,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sBAAsB,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -67,6 +67,15 @@ program
|
|
|
67
67
|
|
|
68
68
|
program.parse(process.argv);
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Find the maximum number of consecutive backticks in a string
|
|
72
|
+
*/
|
|
73
|
+
const findMaxConsecutiveBackticks = (str: string): number => {
|
|
74
|
+
const matches = str.match(/`+/g);
|
|
75
|
+
if (!matches) return 0;
|
|
76
|
+
return Math.max(...matches.map((m) => m.length));
|
|
77
|
+
};
|
|
78
|
+
|
|
70
79
|
/**
|
|
71
80
|
* Get file content with markdown format
|
|
72
81
|
*/
|
|
@@ -74,14 +83,18 @@ const getFileContent = async (filePath: string): Promise<string> => {
|
|
|
74
83
|
try {
|
|
75
84
|
const content = await readFile(filePath, 'utf-8');
|
|
76
85
|
const extension = path.extname(filePath).replace('.', '');
|
|
86
|
+
const maxBackticks = findMaxConsecutiveBackticks(content);
|
|
87
|
+
const wrapper = '`'.repeat(Math.max(3, maxBackticks + 1));
|
|
88
|
+
|
|
77
89
|
return (
|
|
78
|
-
|
|
90
|
+
wrapper +
|
|
79
91
|
extension +
|
|
80
92
|
'\n' +
|
|
81
93
|
`// ${filePath}\n\n` +
|
|
82
94
|
content +
|
|
83
95
|
'\n' +
|
|
84
|
-
|
|
96
|
+
wrapper +
|
|
97
|
+
'\n\n'
|
|
85
98
|
);
|
|
86
99
|
} catch (e) {
|
|
87
100
|
console.error(`Error reading file ${filePath}:`, e);
|