Skip to content

Commit ae8999b

Browse files
chore: shit code!
1 parent 07ef621 commit ae8999b

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

src/generators/file.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@ export const file = defineGenerator({
1919

2020
const lines = contents.split("\n");
2121

22+
console.log(lines);
23+
2224
const startLine = _startLine === "" ? 0 : Number(_startLine);
2325
const endLine = _endLine === "" ? lines.length : Number(_endLine);
2426

2527
if (startLine < 1) {
2628
throw new Error("first line's index can not be smaller than 1");
2729
}
28-
if (endLine > lines.length) {
29-
throw new Error(
30-
`line ${endLine} was specified while file ${fullPath} has only ${lines.length} lines`,
31-
);
32-
}
3330

34-
contents = lines.slice(startLine - 1, endLine - 1).join("\n");
31+
contents = lines.slice(startLine - 1, endLine).join("\n");
3532
}
3633

3734
if (args.code) {

test/fixture/INPUT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
## `file`
3939

40-
<!-- automd:file src="./TEST.md" from-line=1 to-line=5 -->
40+
<!-- automd:file src="./TEST.md" lines=1:5 -->
4141
<!-- /automd -->
4242

4343
## `contributors`

test/fixture/OUTPUT.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,14 @@ Why waste time solving problems when someone else has already done it for you? S
190190

191191
## `file`
192192

193-
<!-- automd:file src="./TEST.md" from-line=1 to-line=5 -->
193+
<!-- automd:file src="./TEST.md" lines=1:5 -->
194194

195195
## The Lazy Coder's Guide to Programming
196196

197197
Programming can be hard. But fear not! With the power of copy-paste, you can conquer any coding challenge without breaking a sweat. Just remember: if it works once, it'll work a thousand times. Who needs original code anyway?
198198

199199
When your code doesn't work, don't blame yourself. It's clearly the compiler's fault for not understanding your genius. Remember, the more error messages you get, the closer you are to becoming a programming master.
200200

201-
Why waste time solving problems when someone else has already done it for you? Stack Overflow is your best friend, your mentor, and your savior. Just make sure to upvote the answers that save your bacon.
202-
203201
<!-- /automd -->
204202

205203
## `contributors`

0 commit comments

Comments
 (0)