Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
file-utils
Advanced tools
This is a Grunt.file forks to allow the creation of scoped file utilities and the ability to add write filters.
Same as Grunt.file, this is a set of synchronous utility. As so, it should never be used on a Node.js server. This is meant for users/command line utilities.
var file = require('file-utils');
var env = file.createEnv({
base: 'my/scoped/path'
});
file-utils
root module options are inherited by the Env
instance if not overwritten in the option hash.
Write filters are applied on env.write
and env.copy
.
env.registerWriteFilter( name, filter )
options
name
(String): The name under which registering the filterfilter
(Function): The filter functionThe filter function take a file object as parameter. This file object is a hash containing a path
and a contents
property. You can modify these two property as you like and returning the modified object.
env.registerWriteFilter( 'coffee', function( file ) {
if (!path.extname(file) !== '.js') return file;
file.path = file.path.replace(/(\.js)$/, '.coffee');
file.content = convertJsToCoffee( file.contents );
return file;
});
env.removeWriteFilter( name )
env.removeWriteFilter('coffee');
Upcoming. Meanwhile, check Grunt.file documentation.
file.option( name, [ value ])
// Set option
file.option('write', false);
// Get option
file.option('write');
Available Options
write
(Boolean): If write is set to false
, then no file will be written or deleted. Useful for test run without side effets.logger
(Logger object): Used internally to log information to the console. API still work in progressencoding
(String): Defaults utf8
. Set the default encoding used for reading/writing. Note most methods allow you to overwridde it for a single run.force
(Boolean): force: true
Force the deletion of folders and file outside the utility scope (or CWD if no scope).FAQs
Sync file utility for Node.js command line tools
The npm package file-utils receives a total of 3,862 weekly downloads. As such, file-utils popularity was classified as popular.
We found that file-utils 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
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.