Gathering detailed insights and metrics for @umijs/mem-fs-editor
Gathering detailed insights and metrics for @umijs/mem-fs-editor
Gathering detailed insights and metrics for @umijs/mem-fs-editor
Gathering detailed insights and metrics for @umijs/mem-fs-editor
File edition helpers working on top of mem-fs (https://github.com/SBoudrias/mem-fs)
npm install @umijs/mem-fs-editor
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
165 Commits
17 Branches
1 Contributors
Updated on Mar 12, 2022
Latest Version
6.0.2
Package Id
@umijs/mem-fs-editor@6.0.2
Unpacked Size
20.38 kB
Size
6.23 kB
File Count
17
NPM Version
6.9.0
Node Version
10.19.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
File edition helpers working on top of mem-fs
1var memFs = require('mem-fs'); 2var editor = require('mem-fs-editor'); 3 4var store = memFs.create(); 5var fs = editor.create(store); 6 7fs.write('somefile.js', 'var a = 1;');
#read(filepath, [options])
Read a file and return its contents as a string.
You can alternatively get the raw contents buffer if you pass options.raw = true
.
By default, calling read()
on a file path that does not exist throws error. You can, however, pass options.defaults = 'your default content'
to get a default content you pass in, if you prefer to not deal with try/catch.
#readJSON(filepath, [defaults])
Read a file and parse its contents as JSON.
readJSON()
internally calls read()
but will not throw an error if the file path you pass in does not exist. If you pass in an optional defaults
, the defaults
content will be returned in case of the target file is missing, instead of undefined
. (Error would still be thrown if JSON.parse
failed to parse your target file.)
#write(filepath, contents)
Replace the content of a file (existing or new) with a string or a buffer.
#writeJSON(filepath, contents[, replacer [, space]])
Replace the content of a file (existing or new) with an object that is to be converted by calling JSON.stringify()
.
contents
should usually be a JSON object, but it can technically be anything that is acceptable by JSON.stringify.
Optionally pass replacer
and space
as the last two arguments, as defined by JSON.stringify. spacer
is used to format the output string (prettify).
Default value for space
is 2
, when not specified.
#append(filepath, contents, [options])
Append the new contents to the current file contents.
options.trimEnd
(default true
). Trim trailing whitespace of the current file contents.options.separator
(default os.EOL
). Separator to insert between current and new contents.#extendJSON(filepath, contents[, replacer [, space]])
Extend the content of an existing JSON file with the partial objects provided as argument.
Optionally take the same JSON formatting arguments than #writeJSON()
.
#delete(filepath, [options])
Delete a file or a directory.
filePath
can also be a glob
. If filePath
is glob, you can optionally pass in an options.globOptions
object to change its pattern matching behavior. The full list of options are being described here. The sync
flag is forced to be true
in globOptions
.
#copy(from, to, [options], context[, templateOptions ])
Copy a file from the from
path to the to
path.
Optionally, pass an options.process
function (process(contents)
) returning a string or a buffer who'll become the new file content. The process function will take a single contents argument who is the copied file contents as a Buffer
.
option.ignoreNoMatch
can be used to silence the error thrown if no files match the from
pattern.
from
can be a glob pattern that'll be match against the file system. If that's the case, then to
must be an output directory. For a globified from
, you can optionally pass in an options.globOptions
object to change its pattern matching behavior. The full list of options are being described here. The nodir
flag is forced to be true
in globOptions
to ensure a vinyl object representing each matching directory is marked as deleted
in the mem-fs
store.
#copyTpl(from, to, context[, templateOptions [, copyOptions]])
Copy the from
file and, if it is not a binary file, parse its content as an ejs template where context
is the template context (the variable names available inside the template).
You can optionally pass a templateOptions
object. mem-fs-editor
automatically setup the filename option so you can easily use partials.
You can also optionally pass a copyOptions
object (see copy() documentation for more details).
Templates syntax looks like this:
<%= value %>
<%- include('partial.ejs', { name: 'Simon' }) %>
Dir syntax looks like this:
/some/path/dir<%= value %>/...
Refer to the ejs documentation for more details.
#move(from, to, [options])
Move/rename a file from the from
path to the to
path.
#move
internally uses #copy
and #delete
, so from
can be a glob pattern, and you can provide options.globOptions
with it.
#exists(filepath)
Returns true
if a file exists. Returns false
if the file is not found or deleted.
#commit([filters,] callback)
Persist every changes made to files in the mem-fs store to disk.
If provided, filters
is an array of TransformStream to be applied on a stream of vinyl files (like gulp plugins).
callback
is called once the files are updated on disk.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
59 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More