9 lines
387 B
TypeScript
9 lines
387 B
TypeScript
import path, { dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
import fs, { readdir } from "fs";
|
|
|
|
export function getDirPath(importMetaUrl = import.meta.url) {
|
|
return dirname(new URL(importMetaUrl).pathname).replace(/^\//,''); // /d:/...
|
|
} // use by: getDirname() with real arg. //* 必须带实参,不然返回的还是本文件的目录路径
|
|
|
|
export default getDirPath; |