stdin-glob 1.0.7 → 1.2.0
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/README.md +81 -8
- package/dist/index.js +40 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +65 -4
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ 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
|
-
-
|
|
28
|
+
- **Limit output to a specific number of lines per file** with `--max-lines`
|
|
29
|
+
- **Show line numbers** with `--line-numbers` for better code reference
|
|
30
|
+
- **Auto-copy output** directly to clipboard with `--copy` flag
|
|
29
31
|
- Support for absolute or relative paths
|
|
30
32
|
- Option to show only file paths without content
|
|
31
33
|
- Written in TypeScript
|
|
@@ -44,13 +46,15 @@ stdin-glob [options] [patterns...]
|
|
|
44
46
|
|
|
45
47
|
### Options
|
|
46
48
|
|
|
47
|
-
| Option
|
|
48
|
-
|
|
|
49
|
-
| `--no-content`
|
|
50
|
-
| `--absolute`
|
|
51
|
-
| `-c, --copy`
|
|
52
|
-
| `-
|
|
53
|
-
| `-
|
|
49
|
+
| Option | Description |
|
|
50
|
+
| --------------------- | --------------------------------------------------------------------- |
|
|
51
|
+
| `--no-content` | Do not show file contents, only list matching paths |
|
|
52
|
+
| `--absolute` | Show absolute paths for entries |
|
|
53
|
+
| `-c, --copy` | Copy the output to clipboard instead of printing to console |
|
|
54
|
+
| `-m, --max-lines <n>` | Show only the first N lines of each file (shows full file if omitted) |
|
|
55
|
+
| `-n, --line-numbers` | Display line numbers next to each line, like in IDE sidebars |
|
|
56
|
+
| `-V, --version` | Output the version number |
|
|
57
|
+
| `-h, --help` | Display help information |
|
|
54
58
|
|
|
55
59
|
### Arguments
|
|
56
60
|
|
|
@@ -92,6 +96,75 @@ function add(a, b) {
|
|
|
92
96
|
```
|
|
93
97
|
````
|
|
94
98
|
|
|
99
|
+
### Limit lines per file
|
|
100
|
+
|
|
101
|
+
Show only the first 10 lines of each TypeScript file - perfect for quick overviews:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
stdin-glob "src/**/*.ts" --max-lines 10
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Output:
|
|
108
|
+
|
|
109
|
+
````
|
|
110
|
+
```ts
|
|
111
|
+
// src/index.ts
|
|
112
|
+
|
|
113
|
+
import { Command } from 'commander';
|
|
114
|
+
import { version } from '../package.json';
|
|
115
|
+
import { readFile } from 'fs/promises';
|
|
116
|
+
import glob from 'fast-glob';
|
|
117
|
+
import path from 'path';
|
|
118
|
+
import clipboard from 'clipboardy';
|
|
119
|
+
// ... (23 more lines truncated)
|
|
120
|
+
```
|
|
121
|
+
````
|
|
122
|
+
|
|
123
|
+
### Show line numbers
|
|
124
|
+
|
|
125
|
+
Display line numbers alongside the code, just like in your editor:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
stdin-glob "src/**/*.js" --line-numbers
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Output:
|
|
132
|
+
|
|
133
|
+
````
|
|
134
|
+
```js
|
|
135
|
+
// src/index.js
|
|
136
|
+
|
|
137
|
+
1 | import { Command } from 'commander';
|
|
138
|
+
2 | import { version } from '../package.json';
|
|
139
|
+
3 | import { readFile } from 'fs/promises';
|
|
140
|
+
4 | import glob from 'fast-glob';
|
|
141
|
+
5 | import path from 'path';
|
|
142
|
+
```
|
|
143
|
+
````
|
|
144
|
+
|
|
145
|
+
### Combine with line limits
|
|
146
|
+
|
|
147
|
+
Get a preview with line numbers for better context:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
stdin-glob "src/**/*.ts" --max-lines 5 --line-numbers
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Output:
|
|
154
|
+
|
|
155
|
+
````
|
|
156
|
+
```ts
|
|
157
|
+
// src/index.ts
|
|
158
|
+
|
|
159
|
+
1 | import { Command } from 'commander';
|
|
160
|
+
2 | import { version } from '../package.json';
|
|
161
|
+
3 | import { readFile } from 'fs/promises';
|
|
162
|
+
4 | import glob from 'fast-glob';
|
|
163
|
+
5 | import path from 'path';
|
|
164
|
+
// ... (23 more lines truncated)
|
|
165
|
+
```
|
|
166
|
+
````
|
|
167
|
+
|
|
95
168
|
### Copy to clipboard
|
|
96
169
|
|
|
97
170
|
Copy all TypeScript file contents directly to clipboard:
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,14 @@ program
|
|
|
15
15
|
.description('Expand glob patterns and output file contents and paths')
|
|
16
16
|
.version(package_json_1.version)
|
|
17
17
|
.option('--no-content', 'Do not show file contents, only list matching paths')
|
|
18
|
-
.option('--absolute', 'Show the absolute path for entries')
|
|
19
|
-
.option('-c, --copy', 'Copy the output to clipboard instead of printing to console')
|
|
18
|
+
.option('--absolute', 'Show the absolute path for entries', false)
|
|
19
|
+
.option('-c, --copy', 'Copy the output to clipboard instead of printing to console', false)
|
|
20
|
+
.option('-m, --max-lines <int>', 'Show a limited number of lines in the file. If you not provide a number of lines it will show the full file content.', (value) => {
|
|
21
|
+
if (isNaN(parseInt(value)))
|
|
22
|
+
throw new Error('Lines must be a number');
|
|
23
|
+
return parseInt(value);
|
|
24
|
+
})
|
|
25
|
+
.option('-n, --line-numbers', 'Show line numbers next to each line, like in IDE sidebars', false)
|
|
20
26
|
.argument('[patterns...]', 'Glob patterns to match files')
|
|
21
27
|
.action(async (patterns, options) => {
|
|
22
28
|
if (patterns.length === 0) {
|
|
@@ -35,7 +41,7 @@ program
|
|
|
35
41
|
let output = '';
|
|
36
42
|
for (const file of files) {
|
|
37
43
|
if (options.content) {
|
|
38
|
-
const fileOutput = await getFileContent(file);
|
|
44
|
+
const fileOutput = await getFileContent(file, options.maxLines ?? undefined, options.lineNumbers ?? false);
|
|
39
45
|
output += fileOutput;
|
|
40
46
|
}
|
|
41
47
|
else {
|
|
@@ -66,20 +72,49 @@ const findMaxConsecutiveBackticks = (str) => {
|
|
|
66
72
|
return 0;
|
|
67
73
|
return Math.max(...matches.map((m) => m.length));
|
|
68
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Add line numbers to content
|
|
77
|
+
*/
|
|
78
|
+
const addLineNumbers = (content, startLine = 1) => {
|
|
79
|
+
const lines = content.split('\n');
|
|
80
|
+
// calculate width of bar
|
|
81
|
+
const paddingWidth = (startLine + lines.length - 1).toString().length;
|
|
82
|
+
return lines
|
|
83
|
+
.map((line, index) => {
|
|
84
|
+
const lineNumber = startLine + index;
|
|
85
|
+
const paddedNumber = lineNumber.toString().padStart(paddingWidth, ' ');
|
|
86
|
+
return `${paddedNumber} | ${line}`;
|
|
87
|
+
})
|
|
88
|
+
.join('\n');
|
|
89
|
+
};
|
|
69
90
|
/**
|
|
70
91
|
* Get file content with markdown format
|
|
92
|
+
* @param filePath - The path to the file
|
|
93
|
+
* @param maxLines - The number of lines to show. If you not provide a number of lines it will show the full file content.
|
|
94
|
+
* @param showLineNumbers - Whether to show line numbers
|
|
95
|
+
* @returns The file content with markdown format
|
|
71
96
|
*/
|
|
72
|
-
const getFileContent = async (filePath) => {
|
|
97
|
+
const getFileContent = async (filePath, maxLines, showLineNumbers) => {
|
|
73
98
|
try {
|
|
74
99
|
const content = await (0, promises_1.readFile)(filePath, 'utf-8');
|
|
100
|
+
const lines = content.split('\n');
|
|
101
|
+
// maxLines if exists
|
|
102
|
+
const linesToShow = maxLines ? lines.slice(0, maxLines) : lines;
|
|
103
|
+
let contentToShow = linesToShow.join('\n');
|
|
104
|
+
if (showLineNumbers)
|
|
105
|
+
contentToShow = addLineNumbers(linesToShow.join('\n'), 1);
|
|
75
106
|
const extension = path_1.default.extname(filePath).replace('.', '');
|
|
76
107
|
const maxBackticks = findMaxConsecutiveBackticks(content);
|
|
77
108
|
const wrapper = '`'.repeat(Math.max(3, maxBackticks + 1));
|
|
109
|
+
const truncation = maxLines && lines.length > maxLines
|
|
110
|
+
? `\n// ... (${lines.length - maxLines} more lines truncated)`
|
|
111
|
+
: '';
|
|
78
112
|
return (wrapper +
|
|
79
113
|
extension +
|
|
80
114
|
'\n' +
|
|
81
115
|
`// ${filePath}\n\n` +
|
|
82
|
-
|
|
116
|
+
contentToShow +
|
|
117
|
+
truncation +
|
|
83
118
|
'\n' +
|
|
84
119
|
wrapper +
|
|
85
120
|
'\n\n');
|
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;
|
|
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;AAUnC,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,EAAE,KAAK,CAAC;KACjE,MAAM,CACL,YAAY,EACZ,6DAA6D,EAC7D,KAAK,CACN;KACA,MAAM,CACL,uBAAuB,EACvB,sHAAsH,EACtH,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CACF;KACA,MAAM,CACL,oBAAoB,EACpB,2DAA2D,EAC3D,KAAK,CACN;KACA,Q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AAsB,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -9,6 +9,8 @@ interface Options {
|
|
|
9
9
|
content?: boolean;
|
|
10
10
|
absolute?: boolean;
|
|
11
11
|
copy?: boolean;
|
|
12
|
+
maxLines?: number;
|
|
13
|
+
lineNumbers?: boolean; // Nueva opción
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const program = new Command();
|
|
@@ -18,10 +20,24 @@ program
|
|
|
18
20
|
.description('Expand glob patterns and output file contents and paths')
|
|
19
21
|
.version(version)
|
|
20
22
|
.option('--no-content', 'Do not show file contents, only list matching paths')
|
|
21
|
-
.option('--absolute', 'Show the absolute path for entries')
|
|
23
|
+
.option('--absolute', 'Show the absolute path for entries', false)
|
|
22
24
|
.option(
|
|
23
25
|
'-c, --copy',
|
|
24
26
|
'Copy the output to clipboard instead of printing to console',
|
|
27
|
+
false,
|
|
28
|
+
)
|
|
29
|
+
.option(
|
|
30
|
+
'-m, --max-lines <int>',
|
|
31
|
+
'Show a limited number of lines in the file. If you not provide a number of lines it will show the full file content.',
|
|
32
|
+
(value) => {
|
|
33
|
+
if (isNaN(parseInt(value))) throw new Error('Lines must be a number');
|
|
34
|
+
return parseInt(value);
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
.option(
|
|
38
|
+
'-n, --line-numbers',
|
|
39
|
+
'Show line numbers next to each line, like in IDE sidebars',
|
|
40
|
+
false,
|
|
25
41
|
)
|
|
26
42
|
.argument('[patterns...]', 'Glob patterns to match files')
|
|
27
43
|
.action(async (patterns: string[], options: Options) => {
|
|
@@ -45,7 +61,11 @@ program
|
|
|
45
61
|
|
|
46
62
|
for (const file of files) {
|
|
47
63
|
if (options.content) {
|
|
48
|
-
const fileOutput = await getFileContent(
|
|
64
|
+
const fileOutput = await getFileContent(
|
|
65
|
+
file,
|
|
66
|
+
options.maxLines ?? undefined,
|
|
67
|
+
options.lineNumbers ?? false,
|
|
68
|
+
);
|
|
49
69
|
output += fileOutput;
|
|
50
70
|
} else {
|
|
51
71
|
output += file + '\n';
|
|
@@ -76,22 +96,63 @@ const findMaxConsecutiveBackticks = (str: string): number => {
|
|
|
76
96
|
return Math.max(...matches.map((m) => m.length));
|
|
77
97
|
};
|
|
78
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Add line numbers to content
|
|
101
|
+
*/
|
|
102
|
+
const addLineNumbers = (content: string, startLine: number = 1): string => {
|
|
103
|
+
const lines = content.split('\n');
|
|
104
|
+
|
|
105
|
+
// calculate width of bar
|
|
106
|
+
const paddingWidth = (startLine + lines.length - 1).toString().length;
|
|
107
|
+
|
|
108
|
+
return lines
|
|
109
|
+
.map((line, index) => {
|
|
110
|
+
const lineNumber = startLine + index;
|
|
111
|
+
const paddedNumber = lineNumber.toString().padStart(paddingWidth, ' ');
|
|
112
|
+
return `${paddedNumber} | ${line}`;
|
|
113
|
+
})
|
|
114
|
+
.join('\n');
|
|
115
|
+
};
|
|
116
|
+
|
|
79
117
|
/**
|
|
80
118
|
* Get file content with markdown format
|
|
119
|
+
* @param filePath - The path to the file
|
|
120
|
+
* @param maxLines - The number of lines to show. If you not provide a number of lines it will show the full file content.
|
|
121
|
+
* @param showLineNumbers - Whether to show line numbers
|
|
122
|
+
* @returns The file content with markdown format
|
|
81
123
|
*/
|
|
82
|
-
const getFileContent = async (
|
|
124
|
+
const getFileContent = async (
|
|
125
|
+
filePath: string,
|
|
126
|
+
maxLines?: number,
|
|
127
|
+
showLineNumbers?: boolean,
|
|
128
|
+
): Promise<string> => {
|
|
83
129
|
try {
|
|
84
130
|
const content = await readFile(filePath, 'utf-8');
|
|
131
|
+
const lines = content.split('\n');
|
|
132
|
+
|
|
133
|
+
// maxLines if exists
|
|
134
|
+
const linesToShow = maxLines ? lines.slice(0, maxLines) : lines;
|
|
135
|
+
let contentToShow = linesToShow.join('\n');
|
|
136
|
+
|
|
137
|
+
if (showLineNumbers)
|
|
138
|
+
contentToShow = addLineNumbers(linesToShow.join('\n'), 1);
|
|
139
|
+
|
|
85
140
|
const extension = path.extname(filePath).replace('.', '');
|
|
86
141
|
const maxBackticks = findMaxConsecutiveBackticks(content);
|
|
87
142
|
const wrapper = '`'.repeat(Math.max(3, maxBackticks + 1));
|
|
88
143
|
|
|
144
|
+
const truncation =
|
|
145
|
+
maxLines && lines.length > maxLines
|
|
146
|
+
? `\n// ... (${lines.length - maxLines} more lines truncated)`
|
|
147
|
+
: '';
|
|
148
|
+
|
|
89
149
|
return (
|
|
90
150
|
wrapper +
|
|
91
151
|
extension +
|
|
92
152
|
'\n' +
|
|
93
153
|
`// ${filePath}\n\n` +
|
|
94
|
-
|
|
154
|
+
contentToShow +
|
|
155
|
+
truncation +
|
|
95
156
|
'\n' +
|
|
96
157
|
wrapper +
|
|
97
158
|
'\n\n'
|