使用 explorer.exe 打开文件夹 window 或使用 node js 打开 finder
Open a folder window using explorer.exe or finder using node js
我想知道是否有办法通过节点 js 打开文件夹位置。我找到 this library 但它只能打开文件和 URL。
编辑:Fuser 的回答让我走上正轨,我发现了这个:
http://documentup.com/arturadib/shelljs
他的方法或者这个都行。
只需 shell 到 explore
所需的文件夹。
我还没有测试过这段代码,但像这样的东西应该可以工作:
function dirOpen(dirPath) {
let command = '';
switch (process.platform) {
case 'darwin':
command = 'open';
break;
case 'win32':
command = 'explore';
break;
default:
command = 'xdg-open';
break;
}
console.log('execSync', `${command} "${dirPath}"`);
return execSync(`${command} "${dirPath}"`);
}
我想知道是否有办法通过节点 js 打开文件夹位置。我找到 this library 但它只能打开文件和 URL。
编辑:Fuser 的回答让我走上正轨,我发现了这个:
http://documentup.com/arturadib/shelljs
他的方法或者这个都行。
只需 shell 到 explore
所需的文件夹。
我还没有测试过这段代码,但像这样的东西应该可以工作:
function dirOpen(dirPath) {
let command = '';
switch (process.platform) {
case 'darwin':
command = 'open';
break;
case 'win32':
command = 'explore';
break;
default:
command = 'xdg-open';
break;
}
console.log('execSync', `${command} "${dirPath}"`);
return execSync(`${command} "${dirPath}"`);
}