Node.js – process.report.filename 屬性


process.report.filename 屬性用於獲取或設定寫入報告的檔名。如果該值設為空字串,則輸出檔名將根據時間戳、PID 和序列號生成。其預設值為一個空字串。

語法

process.report.filename

範例 1

建立一個名為 "filename.js" 的檔案,並複製以下程式碼片段。建立該檔案後,使用命令 "node filename.js" 來執行此程式碼。

// process.report.directory Property Demo Example

// Importing the process module
const process = require('process');

// Passing the filename
process.report.filename = "tutorialspoint"

// Printing the result
console.log(`Report filename is ${process.report.filename}`)

輸出

Report filename is tutorialspoint

範例 2

我們來看另一個範例。

// process.report.directory Property Demo Example

// Importing the process module
const process = require('process');

// Passing the filename
const filename = process.report.filename;

// Printing the result
if (filename.length == 0)
   console.log("No file name is assigned")
else
   console.log(filename)

輸出

No file name is assigned

更新於: 2021 年 10 月 29 日

74 次瀏覽

開啟你的 職業生涯

完成該課程即可獲得認證

開始
廣告內容
© . All rights reserved.