{"id":16982772,"url":"https://github.com/teplostanski/nreplacer","last_synced_at":"2025-03-22T00:26:19.576Z","repository":{"id":200116096,"uuid":"705190253","full_name":"teplostanski/nreplacer","owner":"teplostanski","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-21T16:57:26.000Z","size":524,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-22T20:49:45.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teplostanski.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-15T10:00:49.000Z","updated_at":"2024-05-15T23:41:50.436Z","dependencies_parsed_at":null,"dependency_job_id":"6b7e3ecb-00c9-4202-a8f5-b7cdda3b194f","html_url":"https://github.com/teplostanski/nreplacer","commit_stats":null,"previous_names":["teplostanski/nreplacer"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teplostanski%2Fnreplacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teplostanski%2Fnreplacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teplostanski%2Fnreplacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teplostanski%2Fnreplacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teplostanski","download_url":"https://codeload.github.com/teplostanski/nreplacer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244888692,"owners_count":20526856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T02:25:48.618Z","updated_at":"2025-03-22T00:26:19.489Z","avatar_url":"https://github.com/teplostanski.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nreplacer\n\nEffortlessly replace text in any text-based file or directory using the power and simplicity of Node.js.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Features](#features)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nInstall `nreplacer` globally for easy access from any directory:\n\n```bash\nnpm install -g nreplacer\n```\n\nOr install it locally for your project:\n\n```bash\nnpm install nreplacer --save-dev\n```\n\n## Usage\n\n#### Replace text in a file or directory using the CLI. You can provide either plain text or regex patterns in the --search parameter:\n\nExample with plain text:\n\n```bash\nnreplacer --file \u003cfilepath or directory\u003e --search \"old-text\" --replace \"new-text\" [--global] [--noprint] [--nocolor]\n```\n\nExample with a regex pattern:\n\n```bash\nnreplacer --file \u003cfilepath or directory\u003e --search \"/\\d{3}-\\d{2}-\\d{4}/g\" --replace \"XXX-XX-XXXX\" [--global] [--noprint] [--nocolor]\n```\n\n| Option        | Description                                                                                                    |\n| ------------- | -------------------------------------------------------------------------------------------------------------- |\n| `--file`      | The path to the file or directory where you want to perform the replacement.                                   |\n| `--search`    | The text or pattern you wish to search for.                                                                    |\n| `--replace`   | The text you wish to replace the searched text/pattern with.                                                   |\n| `--global`    | (Optional) If specified, will replace all occurrences. If omitted, only the first occurrence will be replaced. |\n| `--noverbose` | (Optional) If specified, disables verbose output and only performs the replacement silently.                   |\n| `--noprint`   | (Optional) If specified, suppresses the output printing.                                                       |\n| `--nocolor`   | (Optional) If specified, disables color in the output.                                                         |\n\n---\n\n#### For programmatic usage in your JavaScript or TypeScript projects:\n\nYou can also utilize nreplacer in your JavaScript or TypeScript projects. Here's how you can use the replaceInFiles function:\n\nExample with plain text:\n\n```javascript\nimport { replaceInFiles } from \"nreplacer\";\n\nconst filePathOrDir = 'test.txt';\nconst searchValue = 'old-text';\nconst replaceValue = 'new-text';\nconst globalReplace = true;\n\nreplaceInFiles(filePathOrDir, searchValue, replaceValue, globalReplace);\n```\n\nExample with a regex pattern:\n\n```javascript\n\nimport { replaceInFiles } from \"nreplacer\";\n\nconst filePathOrDir1 = 'test1.txt';\nconst filePathOrDir2 = 'test2.txt';\nconst searchValue = /\\d{3}-\\d{2}-\\d{4}/g; // Searching for patterns like \"123-45-6789\"\nconst replaceValue = 'XXX-XX-XXXX';\nconst globalReplace = true;\n\nconst replaceFunc1 = replaceInFiles\nconst replaceFunc2 = replaceInFiles\n\nawait replaceFunc1(filePathOrDir1, searchValue, replaceValue, globalReplace)\nawait replaceFunc2(filePathOrDir2, searchValue)\n```\n\nBy leveraging these examples, you can efficiently integrate nreplacer into your projects and automate text replacement tasks programmatically.\n\n## Features\n\n- **Fast \u0026 Efficient**: Uses streams for efficient memory usage even with large files.\n- **Flexible**: Supports both global and single occurrence replacements.\n- **Safe**: Checks file type and ensures it's a text-based format before processing.\n- **Intuitive CLI**: Simple and straightforward command line interface.\n- **Regex Support**: Utilize regular expressions for text searching.\n- **Configurable Output**: Control the verbosity and color of the CLI output with flags.\n\n## Recent Updates\n\n- Enhanced output formatting with microsecond precision.\n- Integrated boxen for improved CLI output framing.\n- Added `noprint` option to suppress output.\n- Enhanced CLI output with a bordered box.\n- Regex support added for searching.\n\nCheck out our [Changelog](./CHANGELOG.md) for a detailed history of updates.\n\n## Contributing\n\nWe welcome contributions! Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute.\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 (GPL-3.0). See [LICENSE.md](./LICENSE.md) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteplostanski%2Fnreplacer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteplostanski%2Fnreplacer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteplostanski%2Fnreplacer/lists"}