Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
fs-mock
Advanced tools
Readme
Simple fs mock with posix and windows file system styles.
Unfortunately I don't have any more time to maintain this repository :-(
Don't you want to save me and this project by taking over it?
$ npm install fs-mock
This module does not change original fs module in any way.
If you want to pass this module into other module, you will have to use for example rewire package.
var FS = require('fs-mock');
var fs = new FS({
'var': {}, // empty directory
'var/www/index.php': '', // empty file in /var/www, so directory var is now not empty
'home/david/documents/school/projects': {},
'home': {
'david': {},
'john': {
'password.txt': 'my super password' // file
}
}
});
var myPassword = fs.readFileSync('/home/john/password.txt', {encoding: 'utf8'}); // my super password
If you write some path like this: home/david/documents/school/projects
, it will be automatically expanded and all its
parent directories will be also added to mocked file system.
var fs = new FS({
'Users': {
'David': {
'password.txt': 'my super password'
}
}
}, {
windows: true
});
This will change delimiter from /
to \
and add root directory to c:
.
new FS({ ... }, {
windows: true,
drives: ['c:', 'd:', 'z:']
});
new FS({ ... }, {
windows: true,
drives: ['c:', 'd:', 'z:'],
root: 'z:'
});
Now every path will be saved into z:
drive.
If you want to save paths to custom drives, you need to disable auto saving into options.root
.
new FS({
'c:': {
'Users': {}
},
'x:': {
'xampp': {
'htdocs': {}
}
}
}, {
windows: true,
root: false
});
I haven't got any machine with Windows so all methods (like chmod) works just like in Unix systems. Please let me know if you want to improve this and how.
There are also all *Sync methods.
Calling unsupported methods will throw an exception.
fs.rename()
: yesfs.ftruncate()
: yesfs.truncate()
: yesfs.chown()
: yesfs.fchown()
: yesfs.lchown()
: yesfs.chmod()
: yesfs.fchmod()
: yesfs.lchmod()
: yesfs.stat()
: yesfs.lstat()
: yesfs.fstat()
: yesfs.link()
: yesfs.symlink()
: yes (type argument is ignored)fs.readlink()
: yesfs.realpath()
: yesfs.unlink()
: yesfs.rmdir()
: yesfs.mkdir()
: yesfs.readdir()
: yesfs.close()
: yesfs.open()
: yesfs.utimes()
: yesfs.futimes()
: yesfs.write()
: yesfs.read()
: yesfs.readFile()
: yesfs.writeFile()
: yesfs.appendFile()
: yesfs.watchFile()
: no (use fs.watch())fs.unwatchFile()
: no (use fs.watch())fs.watch()
: yes (persistent option is ignored)fs.exists()
: yesfs.createReadStream()
: yesfs.createWriteStream()
: yesdev
: noino
: nomode
: yesnlink
: nouid
: yesgid
: yesrdev
: nosize
: yesblksize
: yesblocks
: yesatime
: yesmtime
: yesctime
: yesisFile()
: yesisDirectory()
: yesisBlockDevice()
: noisCharacterDevice()
: noisSymbolicLink()
: yesisFIFO()
: noisSocket()
: no$ npm test
1.2.0 - 1.2.1
1.1.3
1.1.2
1.1.1
fd
in options1.1.0
1.0.1
1.0.0
FAQs
[ABANDONED] Simple fs mock with posix and windows file system styles
The npm package fs-mock receives a total of 89 weekly downloads. As such, fs-mock popularity was classified as not popular.
We found that fs-mock 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.