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.
The 'touch' npm package is used to create and update the access and modification times of files, similar to the Unix touch command.
Create a new file
This feature allows you to create a new file named 'newfile.txt'. If the file already exists, it updates the access and modification times.
const touch = require('touch');
touch('newfile.txt', function(err) {
if (err) throw err;
console.log('File created');
});
Update access and modification times
This feature updates the access and modification times of an existing file named 'existingfile.txt' to the current date and time.
const touch = require('touch');
touch('existingfile.txt', { time: new Date() }, function(err) {
if (err) throw err;
console.log('Timestamps updated');
});
Force create a file
This feature forces the creation of a file named 'forcefile.txt' even if the parent directory does not exist.
const touch = require('touch');
touch('forcefile.txt', { force: true }, function(err) {
if (err) throw err;
console.log('File created or updated with force');
});
The 'fs-extra' package provides additional file system methods that aren't included in the native 'fs' module. It includes methods for creating and updating files, similar to 'touch', but also offers a wider range of file system operations like copying, moving, and removing files and directories.
The 'node-fs' package extends the native 'fs' module with additional file system methods. It includes functionality for creating and updating files, similar to 'touch', but also provides methods for recursive directory creation and symbolic link management.
The 'file-system' package is a simple wrapper around the native 'fs' module that provides additional convenience methods for file operations. It includes methods for creating and updating files, similar to 'touch', but also offers methods for reading and writing JSON files and working with directories.
For all your node touching needs.
npm install touch
See man touch
This package exports a binary called nodetouch
that works mostly
like the unix builtin touch(1)
.
var touch = require("touch")
Gives you the following functions:
touch(filename, options, cb)
touch.sync(filename, options)
touch.ftouch(fd, options, cb)
touch.ftouchSync(fd, options)
force
like touch -f
Booleantime
like touch -t <date>
Can be a Date object, or any parseable
Date string, or epoch ms number.atime
like touch -a
Can be either a Boolean, or a Date.mtime
like touch -m
Can be either a Boolean, or a Date.ref
like touch -r <file>
Must be path to a file.nocreate
like touch -c
BooleanIf neither atime
nor mtime
are set, then both values are set. If
one of them is set, then the other is not.
FAQs
like touch(1) in node
The npm package touch receives a total of 5,799,891 weekly downloads. As such, touch popularity was classified as popular.
We found that touch demonstrated a healthy version release cadence and project activity because the last version was released less than 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.