Comparing version 0.2.3 to 0.2.4
34
index.js
@@ -138,4 +138,3 @@ 'use strict'; | ||
console.log(e); | ||
return; | ||
return false; | ||
} | ||
@@ -248,7 +247,12 @@ }; | ||
// opt | ||
const opt = {encoding:'utf8'}; | ||
options = options || opt; | ||
return fs.readFileSync(filePath, options); | ||
try{ | ||
// opt | ||
const opt = {encoding:'utf8'}; | ||
options = options || opt; | ||
return fs.readFileSync(filePath, options); | ||
}catch(e){ | ||
console.log(e); | ||
return; | ||
} | ||
}; | ||
@@ -266,7 +270,13 @@ | ||
// vars | ||
fileData = fileData || ''; | ||
options = options || {}; | ||
fs.writeFileSync(filePath, fileData, options); | ||
try{ | ||
// vars | ||
fileData = fileData || ''; | ||
options = options || {}; | ||
fs.writeFileSync(filePath, fileData, options); | ||
return true; | ||
}catch(e){ | ||
console.log(e); | ||
return false; | ||
} | ||
}; | ||
@@ -273,0 +283,0 @@ |
{ | ||
"name": "qiao-file", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "nodejs file tool", | ||
@@ -24,3 +24,3 @@ "author": "uikoo9 <uikoo9@qq.com>", | ||
}, | ||
"gitHead": "22d02248eabd42498ffe164f5115dfcb0fc52552" | ||
"gitHead": "c4c9f755e701d298bb3a9bc397f4178984f6af98" | ||
} |
@@ -43,4 +43,3 @@ 'use strict'; | ||
console.log(e); | ||
return; | ||
return false; | ||
} | ||
@@ -47,0 +46,0 @@ }; |
@@ -28,7 +28,12 @@ 'use strict'; | ||
// opt | ||
const opt = {encoding:'utf8'}; | ||
options = options || opt; | ||
return fs.readFileSync(filePath, options); | ||
try{ | ||
// opt | ||
const opt = {encoding:'utf8'}; | ||
options = options || opt; | ||
return fs.readFileSync(filePath, options); | ||
}catch(e){ | ||
console.log(e); | ||
return; | ||
} | ||
}; | ||
@@ -46,7 +51,13 @@ | ||
// vars | ||
fileData = fileData || ''; | ||
options = options || {}; | ||
fs.writeFileSync(filePath, fileData, options); | ||
try{ | ||
// vars | ||
fileData = fileData || ''; | ||
options = options || {}; | ||
fs.writeFileSync(filePath, fileData, options); | ||
return true; | ||
}catch(e){ | ||
console.log(e); | ||
return false; | ||
} | ||
}; |
17967
605