12345678910111213141516171819202122232425 |
- import { resolve, join, extname, basename, dirname } from 'node:path';
- export function testJoin() {
- console.log(join('/foo', 'bar', 'baz/asdf', 'quux', '..'));
- }
- export function testResolve() {
- console.log(resolve('/foo/bar', './baz'));
- console.log(resolve('/foo/bar', '/tmp/file/'));
- console.log(resolve('wwwroot', 'static_files/png/', '../gif/image.gif'));
-
-
- }
- export function otherMethods() {
- const filePath = './a/b/c/d.md';
-
- console.log('后缀名:', extname(filePath));
-
- console.log('文件名:', basename(filePath));
-
- console.log('文件的目录层级:', dirname(filePath));
- }
|