Skip to content

Commit 7dd1173

Browse files
authored
Accept URL and {file: URL} (#23)
1 parent d294ee3 commit 7dd1173

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

index.test-d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ expectType<EditorInfo>(
3030
line: 10,
3131
column: 2,
3232
},
33+
new URL('file://path/to/file'),
34+
{
35+
file: new URL('file://path/to/file'),
36+
},
3337
]),
3438
);
3539

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"dependencies": {
5353
"env-editor": "^1.1.0",
5454
"execa": "^9.3.0",
55-
"line-column-path": "^3.0.0",
55+
"line-column-path": "^4.0.0",
5656
"open": "^10.1.0"
5757
},
5858
"devDependencies": {

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Open the given files in the user's editor at specific line and column if support
4949

5050
#### files
5151

52-
Type: `Array<string | object>`
52+
Type: `Array<string | URL | object>`
5353

5454
Items should be in the format `foo.js:1:5` or `{file: 'foo.js', line: 1: column: 5}`.
5555

test.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import url from 'node:url';
2+
import path from 'node:path';
13
import test from 'ava';
24
import {getEditorInfo} from './index.js';
35

46
const fixtureFiles = [
57
'unicorn.js:10:20',
68
'rainbow.js:43:4',
79
];
10+
const fixturePath = path.resolve('/foo.js');
11+
const fixtureUrl = url.pathToFileURL(fixturePath);
812

9-
test('object input', t => {
13+
test('files', t => {
1014
t.deepEqual(
1115
getEditorInfo(
1216
[
@@ -31,6 +35,29 @@ test('object input', t => {
3135
isTerminalEditor: false,
3236
},
3337
);
38+
t.deepEqual(
39+
getEditorInfo(
40+
[
41+
fixtureUrl,
42+
{
43+
file: fixtureUrl,
44+
line: 43,
45+
column: 4,
46+
},
47+
],
48+
{
49+
editor: 'sublime',
50+
},
51+
),
52+
{
53+
binary: 'subl',
54+
arguments: [
55+
`${fixturePath}:1:1`,
56+
`${fixturePath}:43:4`,
57+
],
58+
isTerminalEditor: false,
59+
},
60+
);
3461
});
3562

3663
test('editor - generic', t => {

0 commit comments

Comments
 (0)