Node.js process.report.filename 属性
process.report.filename是进程模块内Process 类的内置应用程序编程接口,用于获取或设置报告写入的文件名。
句法:
const process.report.filename
参数:此 api 不接受任何参数作为参数。
返回值:此 api 返回写入报告的文件名。
示例 1:
index.js
// Node.js program to demonstrate the
// Process.report.filename Property
// Importing process module
const process = require('process');
// Assigning the file name
process.report.filename = "GFG"
// Display the result
console.log(process.report.filename)
index.js
// Node.js program to demonstrate the
// Process.report.filename Property
// Importing process module
const process = require('process');
const filename = process.report.filename;
// Display the result
if (filename.length == 0)
console.log("No file name is assigned")
else
console.log(filename)
使用以下命令运行index.js文件:
node index.js
输出:
GFG
示例 2:
index.js
// Node.js program to demonstrate the
// Process.report.filename Property
// Importing process module
const process = require('process');
const filename = process.report.filename;
// Display the result
if (filename.length == 0)
console.log("No file name is assigned")
else
console.log(filename)
使用以下命令运行index.js文件:
node index.js
输出:
No file name is assigned
参考: https://nodejs.org/dist/latest-v16.x/docs/api/process.html#process_process_report_filename