[node] Path Module
const path = require('path');
path.resolve(); // 取得當前資料夾的絕對路徑
path.resolve(__dirname, 'folderName');
path.resolve 和 path.join 的差別
keywords: path.resolve, path.join
/**
* join 是單純把指定的路徑連結在一起
* resolve 會把最後一個帶有 '/' 的路徑當作根目錄,類似 "cd" 的效果
**/
const join = path.join(__dirname, '/a', '/b', 'c'); // directory_path/src/a/b/c
const resolve = path.resolve(__dirname, '/a', '/b', 'c'); // /b/c
path.basename 取的檔案名稱
keywords: path.basename, path.extname, path.parse
const filePath = '/foo/bar/baz/asdf/quux.html';
// 取得檔案和副檔名
path.basename(filePath); // quux.html
// 只要檔案名稱不要附檔名
const extension = path.extname(filePath);
const name = path.basename(filePath, extension); // quux
// 取得詳細的檔案路徑、名稱、副檔名
path.parse(filePath);
// {
// root: '/',
// dir: '/foo/bar/baz/asdf',
// base: 'quux.html',
// ext: '.html',
// name: 'quux'
// }