方法說明
symlink() 的同步版本,用來建立符號鏈接。
語法
fs.symlinkSync(srcpath, dstpath, [type])
此方式屬於 fs 模組,使用前必須先引入:var fs = require("fs")
參數說明
srcpath:來源目錄或檔案的路徑。
dstpath:存放鏈接的路徑,預設為目前工作目錄。
type:預設值為 'file',可選值為 'dir'、'file' 或 'junction',此參數僅在 Windows 上有意義。
注意
Windows 的 junction 類型要求 dstpath 為絕對路徑;使用 'junction' 時,目標參數會自動被正規化為絕對路徑。
原始碼
fs.symlinkSync = function(destination, path, type) {
type = (util.isString(type) ? type : null);
nullCheck(destination);
nullCheck(path);
return binding.symlink(preprocessSymlinkDestination(destination, type),
pathModule._makeLong(path),
type);
};