sdin
Version:
JavaScript package builder.
67 lines (66 loc) • 2.44 kB
TypeScript
export declare const TJSX_FILE_EXTENSIONS: string[];
export declare const TJSXS_FILE_EXTENSIONS: string[];
/**
* 获取本项目的根目录
*/
export declare function getRootPath(): string;
/**
* 获取本项目的根目录下的路径
*/
export declare function withRootPath(path: string): string;
/**
* 获取本项目关联的 node_module 目录下的路径
*/
export declare function withModulePath(importedPath: string): string;
/**
* 获取当前命令行工作目录
*/
export declare function getWorkPath(): string;
/**
* 获取当前命令行工作目录下的路径
*/
export declare function withWorkPath(path: string): string;
export declare function isNonEmptyDir(path: string): Promise<boolean>;
export declare function dirExistOrThrow(path: string): Promise<void>;
export declare function fileExistOrThrow(path: string): Promise<void>;
/**
* 查询路径下对应的文件是否存在,存在则返回路径,否则返回空字符串
* resolveExtends('/path/to', 'index', ['.tsx', '.ts', '.jsx', '.js'])
*/
export declare function resolveExtensionSync(path: string, filename: string, extensions: string[]): string;
/**
* 查询路径下对应的文件是否存在,存在则返回路径,否则返回空字符串
* resolveExtends('/path/to', 'index', ['.tsx', '.ts', '.jsx', '.js'])
*/
export declare function resolveExtension(path: string, filename: string, extensions: string[]): Promise<string>;
/**
* 移除路径前后的空格和斜杠,并根据需要,添加斜杠
*/
export declare function resolvePosixSlash(path: string, startSlash?: boolean, endSlash?: boolean): string;
/**
* 转成 posix 路径碎片
*/
export declare function getPosixPathSegments(path: string): string[];
/**
* 转成 posix 路径
*/
export declare function getPosixPath(path: string): string;
/**
* 用 / 连接路径
*/
export declare function resolvePosix(...pathSegments: string[]): string;
/**
* 用 / 连接路径
*/
export declare function joinPosix(...pathSegments: string[]): string;
/**
* 换成别名,换不成,就返回空
*/
export declare function aliasPosix(path: string, alias: Record<string, string>): string | undefined;
/**
* 计算 path2 相对于 path1 的路径,返回的路径以 '/' 为分隔符
*
* relativePosix('/src\\index.js', '/src/utils//array.js')
* result === './utils/array.js'
*/
export declare function relativePosix(path1: string, path2: string): string;