Skip to content

Commit 5f69baf

Browse files
committed
Fix and test a bug and some typos
1 parent 4579a5a commit 5f69baf

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/analysis/dependency-parser.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import type {DiagnosticWithoutFile, Range, Result} from '../error.js';
99
/**
1010
* Parse a Wireit dependency specifier.
1111
*
12-
* A Wireit dependency string is what appears in a `"wireit.<script>.dependencies"` array in a
13-
* `package.json` file, which controls which script must run before the current one.
12+
* A Wireit dependency specifier is what appears in a
13+
* `"wireit.<script>.dependencies"` array in a `package.json` file, which
14+
* controls which script must run before the current one.
1415
*
1516
*
1617
* ### QUICK EXAMPLES
@@ -54,8 +55,9 @@ import type {DiagnosticWithoutFile, Range, Result} from '../error.js';
5455
*
5556
* ### INVERSION
5657
*
57-
* A dependency specifier can be inverted by prefixing it with a `!`. This means that any matching
58-
* scripts will be excluded from the preceding (but not following) matching scripts.
58+
* A dependency specifier can be inverted by prefixing it with a `!`. This means
59+
* that any matching scripts will be excluded from the preceding (but not
60+
* following) matching scripts.
5961
*
6062
* | | |
6163
* |---------------------------|-------------------------------------------------------------------|
@@ -65,7 +67,8 @@ import type {DiagnosticWithoutFile, Range, Result} from '../error.js';
6567
*
6668
* ### ESCAPING
6769
*
68-
* The following characters have special meaning, and must be escaped with `\` if meant literally:
70+
* The following characters have special meaning, and must be escaped with `\`
71+
* if meant literally:
6972
*
7073
* | | |
7174
* |---------------------------|-------------------------------------------------------------------|
@@ -153,7 +156,7 @@ type Segment = StringSegment | SpecialSegment;
153156
type StringSegment = {
154157
kind: 'string';
155158
string: string;
156-
// Note this can be range can be longe than the length of `string`, since it
159+
// Note this can be range can be longer than the length of `string`, since it
157160
// includes escapes.
158161
range: Range;
159162
};
@@ -486,10 +489,10 @@ class DependencyParser {
486489
#lookAheadForUnescapedHash(): boolean {
487490
for (let i = this.#pos + 1; i < this.#str.length; i++) {
488491
const char = this.#str[i];
489-
if (char === BACKSLASH) {
490-
i += 2;
491-
} else if (char === HASH) {
492+
if (char === HASH) {
492493
return true;
494+
} else if (char === BACKSLASH) {
495+
i++; // Skip an additional character (since it's escaped).
493496
}
494497
}
495498
return false;

src/test/dependency-parser.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ const cases: Array<
185185
script: {kind: 'name', name: 'foo#scr'},
186186
},
187187
],
188+
[
189+
String.raw`./pkg:foo\##scr`,
190+
String.raw`PPPPPPPPPPP_SSS`,
191+
{
192+
package: {kind: 'path', path: './pkg:foo#'},
193+
script: {kind: 'name', name: 'scr'},
194+
},
195+
],
188196
[
189197
'#foo',
190198
'_SSS',

0 commit comments

Comments
 (0)