Comparing version 0.2.2 to 0.2.3
18
index.js
@@ -254,2 +254,19 @@ 'use strict'; | ||
/** | ||
* writeFile | ||
* @param {*} filePath | ||
* @param {*} fileData | ||
* @param {*} options https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#fswritefilesyncfile-data-options | ||
*/ | ||
const writeFile = (filePath, fileData, options) => { | ||
// check | ||
if(!filePath) return; | ||
// vars | ||
fileData = fileData || ''; | ||
options = options || {}; | ||
fs.writeFileSync(filePath, fileData, options); | ||
}; | ||
exports.fs = fs; | ||
@@ -266,1 +283,2 @@ exports.path = path; | ||
exports.rm = rm; | ||
exports.writeFile = writeFile; |
{ | ||
"name": "qiao-file", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "nodejs file tool", | ||
@@ -24,3 +24,3 @@ "author": "uikoo9 <uikoo9@qq.com>", | ||
}, | ||
"gitHead": "351406b4394e71e571f10589f62911a34d76f7b8" | ||
"gitHead": "22d02248eabd42498ffe164f5115dfcb0fc52552" | ||
} |
@@ -138,2 +138,16 @@ # qiao-file | ||
### writeFile | ||
```javascript | ||
'use strict'; | ||
var q = require('qiao-file'); | ||
var test = function(){ | ||
var filePath = './1.js'; | ||
q.writeFile(filePath, '2'); | ||
}; | ||
test(); | ||
``` | ||
## is | ||
@@ -160,2 +174,3 @@ ### isExists | ||
2. mv | ||
3. write file | ||
@@ -162,0 +177,0 @@ ### 0.1.2.20220419 |
@@ -33,2 +33,19 @@ 'use strict'; | ||
return fs.readFileSync(filePath, options); | ||
}; | ||
/** | ||
* writeFile | ||
* @param {*} filePath | ||
* @param {*} fileData | ||
* @param {*} options https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#fswritefilesyncfile-data-options | ||
*/ | ||
export const writeFile = (filePath, fileData, options) => { | ||
// check | ||
if(!filePath) return; | ||
// vars | ||
fileData = fileData || ''; | ||
options = options || {}; | ||
fs.writeFileSync(filePath, fileData, options); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17543
21
583
219