ttsc
Version:
General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.
28 lines (27 loc) • 1.32 kB
TypeScript
/**
* Walk up the directory tree from `__dirname` until a directory that contains
* both `package.json` and `go.mod` is found. This is the `packages/ttsc` root
* and must be passed to `buildNativeCompiler` so it can locate `cmd/ttsc`.
*
* Uses `fs.realpathSync.native` when available to resolve symlinks identically
* to the Go toolchain's own path resolution.
*
* Throws when the root cannot be found (i.e. the package is not in a Go
* workspace), which would indicate a broken installation.
*/
export declare function packageRootDir(): string;
/**
* Walk up the directory tree from `from` looking for a `go.mod` file. Stops
* after `maxDepth` hops so callers can bound the search to a known
* neighbourhood of the plugin source directory.
*
* Returns the absolute path to the first `go.mod` found, or `null` when no
* `go.mod` exists within the depth limit or filesystem root is reached first.
*/
export declare function findNearestGoMod(from: string, maxDepth: number): string | null;
/**
* Return `true` when a relative path escapes its base directory — i.e. starts
* with `..` or is an absolute path. Used by callers that need to guard against
* path traversal before building output keys or spawning subprocesses.
*/
export declare function isOutsideRelativePath(relative: string): boolean;