Skip to content

Commit f558eb0

Browse files
committed
make target dir configurable
1 parent aef8c98 commit f558eb0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import TsServerLibrary, { CodeFixAction, ScriptElementKind } from 'typescript/lib/tsserverlibrary';
2-
import * as path from 'path';
32
import * as namespaceImportPlugin from './lib/import';
43

54
declare global {

src/lib/import.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import ts, { CodeFixAction, ScriptElementKind } from 'typescript/lib/tsserverlibrary';
22
import * as path from 'path';
33

4+
type PluginConfig = {
5+
paths: readonly string[];
6+
};
7+
48
export function getCompletionEntries(info: ts.server.PluginCreateInfo): ts.CompletionEntry[] {
9+
const config = info.config as PluginConfig;
10+
511
const currentDir = info.project.getCurrentDirectory();
6-
const filePaths = info.project.readDirectory(path.resolve(currentDir, 'src/services'), ['.ts', '.js']);
12+
const filePaths = config.paths.flatMap((dirPath) => {
13+
return info.project.readDirectory(path.resolve(currentDir, dirPath), ['.ts', '.js']);
14+
});
715

816
return filePaths.map((filePath) => {
917
const name = getFileNameWithoutExt(filePath);

0 commit comments

Comments
 (0)