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

file-tree-writer

v1.0.1

Published

Utilities for writing trees of files, directories and symbolic links

Downloads

2

Readme

file-tree-writer

This package provides utilities for defining and writing trees of files, e.g. when generating a large number files based on a template.

Install

# With yarn
yarn add file-tree-writer

# With npm
npm install file-tree-writer

Usage

The package exposes the createFileTreeWriter function to create the FileTreeWriter object.

It accepts a FileProps, DirectoryProps or SymbolicLinkProps object that you can create with the File, Directory and SymbolicLink functions. These descriptors contain the name and content of your file and its data (for files), children (for directories) and target for symbolic links. Additionally, you can set the mode of each generated file as a string, number or octal ('777' or '0o777'), owner (as a UID or by username) and group (as a GID or by group name).

You can then asynchronously write the file tree to a directory with fileTreeWriter.writeTo.

The FileTreeWriter object also exposes an EventEmitter-like interface to add event listeners for when a file has been written.

import { createFileTreeWriter, Directory, File, SymbolicLink } from 'file-tree-writer';

const files = Directory({
  name: 'some-dir',
  mode: '755',
  children: [
    File({
      name: 'some-file.txt',
      mode: '644',
      owner: 'root',
      group: 'root',
      data: '...',
    }),
    SymbolicLink({
      name: 'a-symlink',
      target: './some-file.txt',
    }),
  ],
});

const fileTreeWriter = createFileTreeWriter(files);
fileTreeWriter.on('write', e => console.info(`Writing ${e.path}`));

const main = async () => {
  await fileTreeWriter.writeTo('./out');
};

main();

This will print:

Writing out/some-dir
Writing out/some-dir/some-file.txt
Writing out/some-dir/a-symlink

License

MIT