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 🙏

© 2026 – Pkg Stats / Ryan Hefner

command_line_files

v1.3.3

Published

Utility to build an array of files from command line arguments

Downloads

49

Readme

command_line_files

Takes the command line parameters and bulds an array of filenames (including path), after validating that files actually exist. The wild cards are processed using Glob module.

Usage

Install with npm

npm install --save command_line_files
// Example 1: getFilesSync returns an array of filenames and directories
const clf = require('command_line_files');
files = clf.getFilesSync();
console.log("getFilesSync array: "+JSON.stringify(files));
// Example 2: getFilesSync passes an array of filenames to callback function
const clf = require('command_line_files');

clf.getFilesSync( (files) => {
	console.log("getFilesSync array 2: "+JSON.stringify(files));
	files.forEach( (file) => {
		console.log("getFilesSync for each: "+file);
	});
});
// Example 3: processEachFile builds an array of filenames, 
//            and invokes the callback function for each file
const clf = require('command_line_files');

clf.processEachFile( (filename) => {
	console.log("processFiles: "+filename);
});

To improve logging control and to allow for better integration with other modules, introduced integration with primitive_logger See https://www.npmjs.com/package/primitive_logger.

This module uses "command_line_files" message type, so to enable its logs, "command_line_files" should be added to the list of active types.

Examples of using module with logging:

// Example 4 : Enabling "command_line_files" option in logger 
//             to make it print some diagnostics, while calling code
//             doesn't use logger
const clf = require('command_line_files');

clf.getFilesSync( {logger:{types:["command_line_files"]}}, (files) => {
	console.log("getFilesSync array 2: "+JSON.stringify(files));
	files.forEach( (file) => {
		console.log("getFilesSync for each: "+file);
	});
});
// Example 5 : Calling code creates and uses logger and passes it over to CLF module. 
//             The "command_line_files" type is added specifically for CLF module use.
const lr = require('primitive_logger')
const clf = require('command_line_files');

var options = {
	logger: {
		types: ["command_line_files","info"],
		format: { 
			date: {show: true},
			type: {show: true}
		}
	},
	filesList: ["*"]
}
logger = new lr.Logger(options);
options.logger.instance = logger;

clf.processEachFile( options, (filename) => {
    logger.log("info", "Processing file: "+filename);
});

getFilesSync( [options], [callback] )

The function is synchronous. I didn't come up with async use case so far. By default, only existing files on the file system are included in returned array.

  • options {Object}
  • cb {Function}
    • err {Error | null}
    • matches {Array<String>} all valid filenames, passed in on command line or with option filesList

processEachFile( [options], [callback] )

  • options {Object}
  • cb {Function}
    • err {Error | null}
    • matches {String} a filename. The callback is invoked for each filename

Command line patterns

See Glob Primer https://www.npmjs.com/package/glob for command line pattern matching rules.

Options

  • options The options object can be passed in to all functions
    • logger - primitive_logger option definitions. See https://www.npmjs.com/package/primitive_logger for details.
      • "command_line_files" message type is used by this module. If logger.instance is not set, the new instance will be created using logger options.
    • validate - when true, will make sure object exists on the local file system. Default: true
    • slice - can be used to identify how many command line parameters to skip. Default: 2 ("node" and your_script_name.js)
    • files - when true, will include valid filenames, assuming validate is true. Default: true
    • dirs - if true, will include valid directories, assuming validate is true. Default: false
    • scanDirs - when true and directory entered on command line, will recursively scan this directory for files and sub-directories, to include them into result set. Default: true
    • filesList - when provided, utility will use this list instead of looking for command line arguments.

Windows

Please only use forward-slashes in command line expressions.

Again, please see Glob documentation for explanations https://www.npmjs.com/package/glob