file-copier2json
v1.0.0
Published
[![npm version](https://img.shields.io/npm/v/file-copier-cli.svg)](https://www.npmjs.com/package/file-copier-cli) [![Build Status](https://img.shields.io/travis/username/file-copier-cli.svg)](https://travis-ci.org/username/file-copier-cli) [![License](htt
Downloads
2
Readme
File Copier CLI
File Copier CLI is a command-line tool that allows you to easily copy files from a source directory to a JSON file, with the option to ignore specific files and directories. It provides an interactive prompt for configuring the file copying process and supports reading ignore patterns from a .gitignore
file or custom configuration.
Installation
You can install File Copier CLI globally using npm:
npm install -g file-copier
Alternatively, you can install it as a local dependency in your project:
npm install --save-dev file-copier
Usage
To use File Copier CLI, navigate to the directory where you want to copy files from and run the following command:
file-copier
The CLI will prompt you with a series of questions to configure the file copying process:
Use .gitignore: You will be asked if you want to use a
.gitignore
file for specifying ignored files and directories. If you choose yes and a.gitignore
file exists in the current directory, its contents will be used as ignore patterns.Ignore Paths: If you choose not to use a
.gitignore
file, you will be prompted to enter comma-separated paths to ignore. These paths can be file names, directory names, or glob patterns.Output File Name: You will be asked to enter the desired name for the output JSON file. The default value is
output.json
.Output Directory: You will be asked to enter the directory where you want to save the output JSON file. The default value is the current working directory.
After answering the prompts, File Copier CLI will process the files in the current directory and its subdirectories, excluding any ignored files and directories based on the specified ignore patterns. The resulting file data will be saved to the output JSON file in the specified output directory.
Configuration
File Copier CLI supports reading configuration options from a file-copier.config
file located in the current directory. If a file-copier.config
file exists, its options will be used as the default values for the CLI prompts.
The file-copier.config
file should be a JSON file with the following structure:
{
"ignore": [
"node_modules",
"dist",
"*.log"
],
"outputFileName": "output.json",
"outputDirectory": "path/to/output"
}
ignore
: An array of ignore patterns (file names, directory names, or glob patterns) to exclude from the file copying process.outputFileName
: The desired name for the output JSON file.outputDirectory
: The directory where the output JSON file should be saved.
If any of these options are not specified in the file-copier.config
file, the CLI will prompt the user for the missing values.
CLI Options
File Copier CLI supports the following command-line options:
-s, --source <path>
: Specify the source directory path. Defaults to the current working directory.-i, --ignore <file>
: Specify an ignore file path (e.g.,.gitignore
) to read ignore patterns from.
Examples
Copy files from the current directory to output.json
:
file-copier
Copy files from a specific directory to result.json
:
file-copier -s path/to/source -o result.json
Use a custom ignore file:
file-copier -i .myignore
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.
License
This project is licensed under the MIT License.