Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
file-system
Advanced tools
This module make file opertaion apis simple, you don't need to care the dir exits. and the api is same as node's filesystem. This is no exists time cost for this plugin.
var file = require('file-system');
file.mkdir('1/2/3/4/5', [mode], function(err) {});
file.mkdirSync('1/2/3/4/5', [mode]);
file.writeFile('path/test.txt', 'aaa', function(err) {})
npm install file-system --save
file extend node fs origin methods, and overwrite some methods with next list chart if you want to use origin method, choose file.fs[method]
file.existsSync === file.fs.existsSync // true
file.fs.mkdirSync // orign method
The api is same as node's mkdir
The api is same as node's mkdir
The api is same as node's writeFile
The api is same as node's writeFile
Recurse into a directory, executing callback for each file and folder. if the filename is undefiend, the callback is for folder, otherwise for file. And you can pass filter params for filter file.
file.recurse('path', function(filepath, filename) { });
file.recurse('path', [
'*.css',
'**/*.js',
'path/*.html',
'!**/path/*.js'
], function(filepath, filename) {
if (filename) {
// it's file
} else {
// it's folder
}
});
// Only using files
file.recurse('path', function(filepath, filename) {
if (!filename) return;
});
Same as recurse, but it is synchronous
file.recurseSync('path', function(filepath, filename) {
});
file.recurseSync('path', ['**/*.js', 'path/**/*.html'], function(filepath, filename) {
});
Recurse into a directory, remove all of the files and folder in this directory. it also can delete file.
file.rmdirSync('path');
file.rmdirSync('path/file.txt');
Recurse into a directory, copy all files into dest. Pass options filter params to filter files. if you want to change the dest filepath, process callback return { contents: '', filepath: ''}, otherwise only change contents.
file.copySync('path', 'dest', { clear: true });
file.copySync('src', 'dest/src');
file.copySync('src', 'dest/src', { filter: ['*.js', 'path/**/*.css'] });
file.copySync('path', 'dest', {
noProcess: '**/*.{jpg, png}', // Don't process images
process: function(contents, filepath) {
return {
contents: '',
filepath: ''
};
}
});
//Handler self files
file.copySync('path', 'path', { filter: ['*.html.js'], process: function(contents, filepath) {} });
options
Read image file, callback with base64 data
file.base64('img.png', function(err, data) {
});
var base64 = file.base64Sync('img.png');
FAQs
Strengthen the ability of file system
The npm package file-system receives a total of 60,222 weekly downloads. As such, file-system popularity was classified as popular.
We found that file-system demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.