替换程序中所有同步API的调用

This commit is contained in:
lyswhut
2020-04-26 22:08:23 +08:00
parent cdbedf3d64
commit 9ff5147418
9 changed files with 73 additions and 43 deletions
+7 -3
View File
@@ -97,10 +97,14 @@ export const scrollTo = (element, to, duration = 300, fn = () => {}) => {
/**
* 检查路径是否存在
* @param {*} path
* @param {*} path 路径
*/
export const checkPath = path => fs.existsSync(path)
export const checkPath = (path) => new Promise(resolve => {
fs.access(path, fs.constants.F_OK, err => {
if (err) return resolve(false)
resolve(true)
})
})
/**
* 选择路径