Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
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 fs = require('file-system');
fs.mkdir('1/2/3/4/5', [mode], function(err) {});
fs.mkdirSync('1/2/3/4/5', [mode]);
fs.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
var file = require('file-system');
var fs = require('fs');
file.readFile === fs.readFile // true
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
The api equal file-match
Asynchronously copy a file into newpath
srcpath
requireddestpath
requiredoptions
options.encoding
[options.encoding=utf8]options.done(err)
options.process(content)
fs.copyFile('deom.png', 'dest/demo.png', {
done: function(err) {
console.log('done');
}
});
The api same as copyFile, but it's synchronous
fs.copyFileSync('demo.png', 'dest/demo.png');
fs.copyFileSync('demo.css', 'dest/demo.css', {
process: function(contents) {
return contents;
}
})
Recurse into a directory, executing callback for each file and folder. if the filename is undefiend, the callback is for folder, otherwise for file.
dirpath
requiredfilter
callback(filepath, filename)
fs.recurse('path', function(filepath, filename) { });
fs.recurse('path', [
'*.css',
'**/*.js',
'path/*.html',
'!**/path/*.js'
], function(filepath, filename) {
if (filename) {
// it's file
} else {
// it's folder
}
});
// Only using files
fs.recurse('path', function(filepath, filename) {
if (!filename) return;
});
The api is same as recurse, but it is synchronous
fs.recurseSync('path', function(filepath, filename) {
});
fs.recurseSync('path', ['**/*.js', 'path/**/*.html'], function(filepath, filename) {
});
Recurse into a directory, remove all of the files and folder in this directory.
fs.rmdirSync('path');
Recurse into a directory, copy all files into dest.
dirpath
requireddestpath
requiredoptions
options.filter
options.process(contents, filepath, relative)
options.noProcess
fs.copySync('path', 'dest', { clear: true });
fs.copySync('src', 'dest/src');
fs.copySync('src', 'dest/src', { filter: ['*.js', 'path/**/*.css'] });
fs.copySync('path', 'dest', {
noProcess: '**/*.{jpg, png}', // Don't process images
process: function(contents, filepath, relative) {
// only process file content
return contents;
// or custom destpath
return {
contents: '',
filepath: ''
};
}
});
//Handler self files
fs.copySync('path', 'path', { filter: ['*.html.js'], process: function(contents, filepath) {} });
Deprecated, move to base64
Deprecated, move to base64Sync
FAQs
Strengthen the ability of file system
The npm package file-system receives a total of 71,576 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.