@@ -15,6 +15,7 @@ This is a TypeScript port of the original `files-to-prompt` tool written in Pyth
15
15
16
16
Additional features not found the original version:
17
17
- reading and parsing file paths received via ` stdin ` (e.g. via pipe from ` grep ` or ` ripgrep ` )
18
+ - redirect output to a file with ` --output <file> ` or ` -o <file> `
18
19
19
20
[ ^ 1 ] : The script needs a Typescript engine to run, of course.
20
21
@@ -25,13 +26,13 @@ Additional features not found the original version:
25
26
2 . Download the script
26
27
- Install via jsr.io
27
28
``` shell
28
- curl https://jsr.io/@fry69/files-to-prompt-ts/0.2.1 /files-to-prompt.ts > ftp.ts
29
+ curl https://jsr.io/@fry69/files-to-prompt-ts/0.3.0 /files-to-prompt.ts > ftp.ts
29
30
```
30
31
31
32
- Install via GitHub
32
33
33
34
` ` ` shell
34
- curl https://raw.githubusercontent.com/fry69/files-to-prompt-ts/v0.2.1 /files-to-prompt.ts > ftp.ts
35
+ curl https://raw.githubusercontent.com/fry69/files-to-prompt-ts/v0.3.0 /files-to-prompt.ts > ftp.ts
35
36
` ` `
36
37
37
38
3. Make the script executable with ` chmod +x ftp.ts`
@@ -49,9 +50,11 @@ Replace `<paths...>` with one or more paths to files or directories you want to
49
50
50
51
Available options:
51
52
53
+ - `--version`: Version of this script
52
54
- `--include-hidden`: Include files and folders starting with `.` (default: `false`)
53
55
- `--ignore-gitignore`: Ignore `.gitignore` files and include all files (default: `false`)
54
56
- `-i, --ignore <pattern>`: Specify one or more patterns to ignore (can be used multiple times)
57
+ - `-o, --output <file>`: Redirect output to `file` (**Note:** `file` will get silently overwritten)
55
58
56
59
Example usage:
57
60
@@ -83,51 +86,56 @@ This tool includes a set of tests to ensure it works as expected. You can run th
83
86
bun test --coverage
84
87
```
85
88
86
- Recent test status (v0.2.1 ):
89
+ Recent test status (v0.3.0 ):
87
90
88
91
```
89
92
bun test v1.1.4 (fbe2fe0c)
90
93
91
94
files-to-prompt.test.ts:
92
- ✓ files-to-prompt.ts > should include single file passed on the command line [11.59ms ]
93
- ✓ files-to-prompt.ts > should include multiple files passed on the command line [6.86ms ]
94
- ✓ files-to-prompt.ts > should include files in directories passed on the command line [7.73ms ]
95
- ✓ files-to-prompt.ts > should include files a few levels deep in a directory structure [6.64ms ]
95
+ ✓ files-to-prompt.ts > should include single file passed on the command line [11.52ms ]
96
+ ✓ files-to-prompt.ts > should include multiple files passed on the command line [6.67ms ]
97
+ ✓ files-to-prompt.ts > should include files in directories passed on the command line [7.52ms ]
98
+ ✓ files-to-prompt.ts > should include files a few levels deep in a directory structure [6.65ms ]
96
99
✓ files-to-prompt.ts > should exclude files matching patterns passed via --ignore [6.61ms]
97
- ✓ files-to-prompt.ts > should exclude files matching patterns passed via multiple --ignore [6.47ms ]
98
- ✓ files-to-prompt.ts > should fail when --ignore gets passed without an argument [5.89ms ]
99
- ✓ files-to-prompt.ts > should exclude files matching patterns in .gitignore [6.75ms ]
100
- ✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore [8.17ms ]
101
- ✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore in different directories [6.77ms ]
102
- ✓ files-to-prompt.ts > should include hidden files and directories when --include-hidden is passed [6.85ms ]
103
- ✓ files-to-prompt.ts > should ignore .gitignore files when --ignore-gitignore is passed [7.62ms ]
104
- ✓ files-to-prompt.ts > should skip binary files [6.88ms ]
105
- ✓ files-to-prompt.ts > should fail silently if isBinaryFile() gets called with invalid path [1.14ms ]
106
- ✓ files-to-prompt.ts > should skip FIFOs [20.92ms ]
107
- ✓ files-to-prompt.ts > should fail with error message if path does not exist [6.70ms ]
108
- ✓ files-to-prompt.ts > should parse file paths with parseFilePathsFromStdin() correctly [0.32ms ]
100
+ ✓ files-to-prompt.ts > should exclude files matching patterns passed via multiple --ignore [6.57ms ]
101
+ ✓ files-to-prompt.ts > should fail when --ignore gets passed without an argument [6.99ms ]
102
+ ✓ files-to-prompt.ts > should exclude files matching patterns in .gitignore [6.82ms ]
103
+ ✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore [7.99ms ]
104
+ ✓ files-to-prompt.ts > should exclude directory matching patterns in .gitignore in different directories [6.71ms ]
105
+ ✓ files-to-prompt.ts > should include hidden files and directories when --include-hidden is passed [8.19ms ]
106
+ ✓ files-to-prompt.ts > should ignore .gitignore files when --ignore-gitignore is passed [6.46ms ]
107
+ ✓ files-to-prompt.ts > should skip binary files [6.71ms ]
108
+ ✓ files-to-prompt.ts > should fail silently if isBinaryFile() gets called with invalid path [1.18ms ]
109
+ ✓ files-to-prompt.ts > should skip FIFOs [15.07ms ]
110
+ ✓ files-to-prompt.ts > should fail with error message if path does not exist [6.76ms ]
111
+ ✓ files-to-prompt.ts > should parse file paths with parseFilePathsFromStdin() correctly [0.27ms ]
109
112
✓ files-to-prompt.ts > should de-duplicate file paths with parseFilePathsFromStdin() [0.06ms]
110
- ✓ files-to-prompt.ts > should parse file paths with one file path per line [0.07ms ]
113
+ ✓ files-to-prompt.ts > should parse file paths with one file path per line [0.06ms ]
111
114
✓ files-to-prompt.ts > should handle mixed input formats [0.03ms]
112
115
✓ files-to-prompt.ts > should handle empty lines in stdin data [0.03ms]
113
- ✓ files-to-prompt.ts > should handle binary data in stdin [0.09ms ]
116
+ ✓ files-to-prompt.ts > should handle binary data in stdin [0.08ms ]
114
117
✓ files-to-prompt.ts > should handle common text/code files in stdin [0.04ms]
115
- ✓ files-to-prompt.ts > should handle long file paths in stdin [0.26ms ]
116
- ✓ files-to-prompt.ts > should ignore file paths with the null character [0.04ms ]
117
- ✓ files-to-prompt.ts > should ignore file paths with control characters [0.03ms ]
118
+ ✓ files-to-prompt.ts > should handle long file paths in stdin [0.25ms ]
119
+ ✓ files-to-prompt.ts > should ignore file paths with the null character [0.03ms ]
120
+ ✓ files-to-prompt.ts > should ignore file paths with control characters [0.34ms ]
118
121
✓ files-to-prompt.ts > should output version string when --version is passed [0.10ms]
119
- ✓ files-to-prompt.ts > should output error for unsupported options [0.06ms]
122
+ ✓ files-to-prompt.ts > should output error for unsupported options [0.09ms]
123
+ ✓ files-to-prompt.ts > should output to a file when --output is passed [6.80ms]
124
+ ✓ files-to-prompt.ts > should output to a file when -o is passed [7.74ms]
125
+ ✓ files-to-prompt.ts > should output error if --output is passed without a file path [5.84ms]
126
+ ✓ files-to-prompt.ts > should output error if -o is passed without a file path [7.02ms]
127
+ ✓ files-to-prompt.ts > should output error if output file cannot be written [6.02ms]
120
128
--------------------|---------|---------|-------------------
121
129
File | % Funcs | % Lines | Uncovered Line #s
122
130
--------------------|---------|---------|-------------------
123
- All files | 88.00 | 88.38 |
124
- files-to-prompt.ts | 88.00 | 88.38 | 30,41,64,102,229-240,349-351,369-372
131
+ All files | 88.89 | 87.98 |
132
+ files-to-prompt.ts | 88.89 | 87.98 | 46,59,74,85-88,114,152,279-290,417-419,437-440
125
133
--------------------|---------|---------|-------------------
126
134
127
- 28 pass
135
+ 33 pass
128
136
0 fail
129
- 59 expect() calls
130
- Ran 28 tests across 1 files. [165 .00ms]
137
+ 73 expect() calls
138
+ Ran 33 tests across 1 files. [195 .00ms]
131
139
```
132
140
133
141
## Compatibility
0 commit comments