Skip to content

Commit bc8f350

Browse files
chore: shit code!
1 parent 48b567c commit bc8f350

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
@@ -183,16 +183,14 @@ Why waste time solving problems when someone else has already done it for you? S
183183

184184
## `file`
185185

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

188188
## The Lazy Coder's Guide to Programming
189189

190190
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?
191191

192192
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.
193193

194-
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.
195-
196194
<!-- /automd -->
197195

198196
## `contributors`

0 commit comments

Comments
 (0)