修复改回同步时回调未移除, 导致在node v12.10报错的bug

master 1.2.2
宇天 2020-01-02 14:57:44 +08:00
parent af4d9faf0f
commit 4c949fadd7
3 changed files with 18 additions and 14 deletions

View File

@ -1,3 +1,7 @@
# 1.2.1 / 2020-01-02
* [F] 修复改回同步时回调未移除, 导致在node v12.10报错的bug
# 1.2.1 / 2019-08-06 # 1.2.1 / 2019-08-06
* [U] 写操作改回同步 * [U] 写操作改回同步

View File

@ -9,12 +9,6 @@
const FS = require('fs') const FS = require('fs')
const PATH = require('path') const PATH = require('path')
const ERROR_FN = (err, res) => {
if (err) {
console.error(err)
}
}
const Iofs = { const Iofs = {
origin: FS, origin: FS,
@ -94,15 +88,15 @@ const Iofs = {
} }
if (!!append) { if (!!append) {
FS.appendFileSync(file, data, opt, ERROR_FN) FS.appendFileSync(file, data, opt)
} else { } else {
FS.writeFileSync(file, data, opt, ERROR_FN) FS.writeFileSync(file, data, opt)
} }
}, },
//修改权限 //修改权限
chmod(path, mode) { chmod(path, mode) {
FS.chmodSync(path, mode, ERROR_FN) FS.chmodSync(path, mode)
}, },
/** /**
@ -152,9 +146,9 @@ const Iofs = {
list.forEach(it => { list.forEach(it => {
this.rm(it, this.isdir(it)) this.rm(it, this.isdir(it))
}) })
FS.rmdirSync(origin, ERROR_FN) FS.rmdirSync(origin)
} else { } else {
FS.unlinkSync(origin, ERROR_FN) FS.unlinkSync(origin)
} }
}, },
@ -196,7 +190,7 @@ const Iofs = {
this.mkdir(updir) this.mkdir(updir)
} }
FS.mkdirSync(dir, ERROR_FN) FS.mkdirSync(dir)
}, },
/** /**

View File

@ -1,13 +1,19 @@
{ {
"name": "iofs", "name": "iofs",
"version": "1.2.1", "version": "1.2.2",
"description": "Base on native fs module, for easy using.", "description": "Base on native fs module, for easy using.",
"main": "index.js", "main": "index.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/yutent/iofs.git" "url": "https://github.com/yutent/iofs.git"
}, },
"keywords": ["fivejs", "fs", "iofs", "fs.io", "file"], "keywords": [
"fivejs",
"fs",
"iofs",
"fs.io",
"file"
],
"author": "yutent", "author": "yutent",
"license": "MIT" "license": "MIT"
} }