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

webdirlist

v1.0.6

Published

webdirlist is a versatile library designed to list files in a directory. It can be used in both Node.js and browser environments. In static hosting scenarios, it prepares a comprehensive listing of all files within a directory in a `files.txt` file.

Downloads

17

Readme

Webdirlistnpm version

webdirlist is a versatile library designed to list files in a directory. It can be used in both Node.js and browser environments. In static hosting scenarios, it prepares a comprehensive listing of all files within a directory in a files.txt file.

Features

  • Tracedir Command: Generate a files.txt file containing information about all files in a specified directory.
  • getFileList Function: Retrieve a list of files from files.txt or directly from the file system in Node.js.

Installation

Install the package using npm:

npm install webdirlist

Install the package in global, to use tracedir anywhere:

npm install webdirlist -g

CDN Install

Via jsDelivr:

<script src="https://cdn.jsdelivr.net/npm/webdirlist/dist/webdirlist.js"></script>
or
<script type="module">
    import webdirlist from 'https://cdn.jsdelivr.net/npm/webdirlist/dist/webdirlist.esm.js';
</script>

Usage

Generating files.txt

Run the tracedir command with npx:

//after npm install in global:
tracedir <blank for current path, or input the folder path>
tracedir .\node_modules\esbuild\
tracedir 

//in the package root folder:
npx tracedir .\node_modules\esbuild\

This will generate a files.txt in the specified folder. The format are filepath,size,timestamp .DS_Store,thumb.db,__MACOSX,.psd would be ignored by default.

bin/esbuild	9180	1702310819
install.js	10923	1702310819
lib/main.d.ts	21152	1702310819
lib/main.js	88340	1702310819
LICENSE.md	1069	1702310819
package.json	1260	1702310819
README.md	175	1702310819

In the Browser

import webdirlist from 'webdirlist';

//optional, set the current folder, leave blank=auto
webdirlist.getInstance().setCWD();

// Async function to get file list
webdirlist.getInstance().loadDir('node_modules/esbuild').then(async()=>{
    const files=await webdirlist.getInstance().getFileList('node_modules/esbuild/lib',{
        subfolder:true,//optional,default true
        includedExt:['json','png','mp3'],//optional
        excludedExt:['txt'],//optional
        ignoreFiles:['unuse.json'],//optional
        ignoreFolder:['temp'],//optional
    });
    // list of filenames in string array
    //['lib/main.d.ts','lib/main.js']
})

In Node.js

don't need to use loadDir to read files.txt in advance , just run webdirlist.getInstance().getFileList directly

import webdirlist from 'webdirlist';

// Async function to get file list
const files=await webdirlist.getInstance().getFileList('node_modules/esbuild/lib',{
    subfolder:true,//optional,default true
    includedExt:['json','png','mp3'],//optional
    excludedExt:['txt'],//optional
    ignoreFiles:['unuse.json'],//optional
    ignoreFolder:['temp'],//optional
});
// list of filenames in string array
//['lib/main.d.ts','lib/main.js']

node.js's path In the Browser

wrapped path-browserify-esm as webPath

import webdirlist,{webPath} from 'webdirlist';

console.log(webPath.join('asd','zxc','../qwe/rty'));//  "asd/qwe/rty"
webPath.setCWD('http://192.168.1.1')
console.log(webPath.resolve('asd','zxc','../qwe/rty'));//   "http:/192.168.1.1/asd/qwe/rty"

Contributing

Contributions to the project are welcome. Please ensure that your code adheres to the project's coding standards and include tests for new features.

License

webdirlist is MIT licensed.