我是打字稿的新手,需要检查机器上是否安装了某个系统,即windows.我正在考虑通过检查一些文件的存在来做到这一点,但我没有找到如何检查打字稿.有人会知道怎么做吗?
yah*_*avi 13
我发现这种方法要简单得多:
import fs from 'fs';
if (fs.existsSync(path)) {
// File exists in path
} else {
// File doesn't exist in path
}
Run Code Online (Sandbox Code Playgroud)
小智 6
fs.stat(path, (exists) => {
if (exists == null) {
return true;
} else if (exists.code === 'ENOENT') {
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6528 次 |
最近记录: |