npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

filesystem-timestamp-modifier

v0.0.2

Published

This tool enables you to modify the timestamp of files on your macOS or Linux filesystem. Sometimes file modified timestamps are changed accidentally, even if you didn't make actual changes to the file, or if you made a change and then decided to undo it.

Downloads

3

Readme

filesystem-timestamp-modifier

This tool enables you to modify the timestamp of files on your macOS or Linux filesystem. Sometimes file modified timestamps are changed accidentally, even if you didn't make actual changes to the file, or if you made a change and then decided to undo it. Timestamps add context to files, especially when searching for something you've recently modified or when sorting files from oldest last modified to latest modified.

Installation

Install from the NPM registry as a global CLI tool:

$ npm i filesystem-timestamp-modifier -g

Examples

Create a sample file called "testfile":

$ echo "hello world" > ./testfile && ls -lT ./testfile

It should now have whatever the current date and time is for the file's modified time. For example, if it's Sunday, October 9th at 9:50 PM, then you'll see this as the output:

-rw-r--r--  1 james  staff  12 Oct  9 21:50:14 2022 ./testfile

You can now try the examples below to modify the timestamp.

Change timestamp of "testfile to September 2nd, 2021 at 9:02 PM local time.

$ lastmod --file ./testfile --time "September 2, 2021 9:09 PM"

Result:

$ ls -lT ./testfile 
-rw-r--r--  1 james  staff  12 Sep  2 21:09:00 2021 ./testfile

Change timestamp of "testfile" to September 5th, 2021 at 8:01 PM local time.

$ lastmod --file ./testfile --time `node -p "new Date('September 5, 2021 8:01 PM').getTime()"`

This results in:

$ ls -lT ./timestamp
-rw-r--r--  1 james  staff  0 Sep  6 20:01:00 2021 ./testfile

Use as a function in a Node.js codebase

This module can also be used locally inside a codebase.

$ npm i filesystem-timestamp-modifier

Then use it like this:

const updateFileTimestamps = require('filesystem-timestamp-modifier');
updateFileTimestamps('./testfile', new Date('September 5, 2021 8:01 PM').getTime());

Contributing

Cloning and setup

Clone the project and install dependencies:

$ npm i

Run the tests:

$ npm test

NOTE: If running from the source, replace "lastmod" with "node cli.js" in the examples section above.

Run tests within Docker/Podman

npm test runs tests in the development OS, whatever OS you're running on. If making changes to the tests, it's helpful to verify they work in various shell environments. One way to quickly validate this is via container images.

To test on a specific Linux platform, substitute the container image tag with the IMAGE_TAG build-arg. For example, the two entries below show how to run the test on Alpine and Debian after first building test images:

Alpine Linux:

$ docker build --build-arg IMAGE_TAG=16.17.1-alpine3.15 -f Dockerfile -t alpine/lastmod .
$ docker run --rm -it alpine/lastmod

Debian:

$ docker build --build-arg IMAGE_TAG=lts-buster-slim -f Dockerfile -t debian/lastmod .
$ docker run --rm -it debian/lastmod

License

Copyright (c) James Mortensen, 2022 MIT License