forked from thqby/vscode-autohotkey2-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a11ed2
commit 52aa813
Showing
12 changed files
with
1,683 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,7 @@ scripts/* | |
*.js | ||
*.js.map | ||
*.tsbuildinfo | ||
**/dist/**/*.d.ts | ||
**/dist/**/*.d.ts | ||
|
||
# Vitest | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
// Place your ahk2 workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | ||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | ||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | ||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | ||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | ||
// Placeholders with the same ids are connected. | ||
// Example: | ||
// "Print to console": { | ||
// "scope": "javascript,typescript", | ||
// "prefix": "log", | ||
// "body": [ | ||
// "console.log('$1');", | ||
// "$2" | ||
// ], | ||
// "description": "Log output to console" | ||
// } | ||
|
||
"Add unit test": { | ||
"scope": "typescript", | ||
"prefix": "describe", | ||
"body": [ | ||
"describe('$1', () => {", | ||
"\ttest.concurrent.each<", | ||
"\t[", | ||
"\t\tname: string,", | ||
"\t\t\targs: Parameters<typeof $1>,", | ||
"\t\t\texpected: ReturnType<typeof $1>,", | ||
"\t\t]", | ||
"\t>([", | ||
"\t['$2', [$3], $4],", | ||
"\t])('%s', (_name, args, expected) => {", | ||
"\t\tconst result = $1(...args);", | ||
"\t\texpect(result).toBe(expected);", | ||
"\t});", | ||
"});", | ||
], | ||
"description": "Add Vitest test.concurrent.each in a describe block", | ||
}, | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect, test, describe, vi, beforeAll, afterAll } from 'vitest'; | ||
import { resolvePath } from './utils'; | ||
|
||
describe('resolvePath', () => { | ||
beforeAll(() => { | ||
// Mock the behavior of fs.lstatSync | ||
vi.mock('fs', () => ({ | ||
lstatSync: (_path: string) => ({ isSymbolicLink: () => false }), | ||
})); | ||
}); | ||
|
||
afterAll(() => { | ||
vi.restoreAllMocks(); | ||
}); | ||
|
||
test.concurrent.each< | ||
[ | ||
name: string, | ||
args: Parameters<typeof resolvePath>, | ||
expected: ReturnType<typeof resolvePath>, | ||
] | ||
>([ | ||
['empty string', [''], ''], | ||
['absolute path at drive root', ['C:/out.txt'], 'C:/out.txt'], | ||
])('%s', (_name, args, expected) => { | ||
const result = resolvePath(...args); | ||
expect(result).toBe(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { execSync } from 'child_process'; | ||
import { lstatSync, readlinkSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
/** | ||
* Returns the provided path as an absolute path. | ||
* Resolves the provided path against the provided workspace. | ||
* Resolves symbolic links by default. | ||
* Returns empty string if resolution fails. | ||
*/ | ||
export function resolvePath( | ||
path: string | undefined, | ||
workspace?: string, | ||
resolveSymbolicLink = true, | ||
): string { | ||
if (!path) return ''; | ||
const paths: string[] = []; | ||
// If the path does not contain a colon, resolve it relative to the workspace | ||
if (!path.includes(':')) paths.push(resolve(workspace ?? '', path)); | ||
// If there are no slashes or backslashes in the path and the platform is Windows | ||
if (!/[\\/]/.test(path) && process.platform === 'win32') | ||
paths.push(execSync(`where ${path}`, { encoding: 'utf-8' }).trim()); | ||
paths.push(path); | ||
for (let path of paths) { | ||
if (!path) continue; | ||
try { | ||
if (lstatSync(path).isSymbolicLink() && resolveSymbolicLink) | ||
path = resolve(path, '..', readlinkSync(path)); | ||
return path; | ||
} catch {} | ||
} | ||
return ''; | ||
} |
Oops, something went wrong.