open nodejs

javascript 2个月前 PPK
58 0

open  介绍

打开url,文件,可执行文件 跨平台的。这意味着可以在命令行工具和脚本中使用,而不是在浏览器中。

https://github.com/sindresorhus/open

$ npm install open

用法

const open = require('open');

// Opens the image in the default image viewer and waits for the opened app to quit.
await open('unicorn.png', {wait: true});
console.log('The image viewer app quit');

// Opens the URL in the default browser.
await open('https://sindresorhus.com');

// Opens the URL in a specified browser.
await open('https://sindresorhus.com', {app: {name: 'firefox'}});

// Specify app arguments.
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});

// Open an app
await open.openApp('xcode');

// Open an app with arguments
await open.openApp(open.apps.chrome, {arguments: ['--incognito']});

 

版权声明:PPK 发表于 2022-03-11 17:52:52。
转载请注明:open nodejs | 襄音导航