{"id":17068921,"url":"https://github.com/localnerve/picklr","last_synced_at":"2025-06-18T17:38:34.621Z","repository":{"id":3786073,"uuid":"50890232","full_name":"localnerve/picklr","owner":"localnerve","description":"A simple, zero dependency, recursive, text replacer for NodeJS","archived":false,"fork":false,"pushed_at":"2025-02-18T16:26:30.000Z","size":499,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T07:47:16.752Z","etag":null,"topics":["multiple-files","nodejs","text-replace"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/localnerve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"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,"zenodo":null}},"created_at":"2016-02-02T03:09:28.000Z","updated_at":"2025-02-18T16:26:00.000Z","dependencies_parsed_at":"2025-02-18T17:35:22.653Z","dependency_job_id":null,"html_url":"https://github.com/localnerve/picklr","commit_stats":{"total_commits":63,"total_committers":4,"mean_commits":15.75,"dds":0.3015873015873016,"last_synced_commit":"408a4327fdb1775e62d861a22ed6928951bdc7e1"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/localnerve/picklr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localnerve%2Fpicklr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localnerve%2Fpicklr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localnerve%2Fpicklr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localnerve%2Fpicklr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localnerve","download_url":"https://codeload.github.com/localnerve/picklr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localnerve%2Fpicklr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260600416,"owners_count":23034704,"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":["multiple-files","nodejs","text-replace"],"created_at":"2024-10-14T11:15:33.117Z","updated_at":"2025-06-18T17:38:29.610Z","avatar_url":"https://github.com/localnerve.png","language":"JavaScript","readme":"# Picklr\n\n[![npm version](https://badge.fury.io/js/picklr.svg)](http://badge.fury.io/js/picklr)\n![Verify](https://github.com/localnerve/picklr/workflows/Verify/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/localnerve/picklr/badge.svg?branch=master)](https://coveralls.io/r/localnerve/picklr?branch=master)\n\n\u003e \"`Pick` `l`ine \u0026 `r`eplace\"\n\u003e\n\u003e A simple, zero dependency, recursive, text replacer.\n\nUse to update a specific text across multiple file types in a project.\nFinds matching lines in files, based on text or regular expression, and runs a text replacement on just those lines matched*.  \n\\* If you have special cases, you can supply a filter function to exclude those special cases.\n\nYou might be reading this because you're in a pickle where you have to change a line or text pattern across a big project. No worries, picklr allows you to test replacement behavior prior to any updates with actions `echo` and `audit`. It's good to see what would happen prior to any file being updated across a project, and also what files will get omitted from the change set.\n\n## API\nPicklr exports a single function that starts synchronous file processing when invoked.\n\n`function (startDir, options)`\n\n### Options\nA brief description of the options that control file selection and processing:\n  + **action** - {String} `echo|audit|update` The action taken on each file. Defaults to `echo`. Use `echo` and `audit` actions to test the results of picklr with options prior to running `update`.\n    + **echo** - Just output what files could be affected by a change. Tests `includeExts` and `excludeDirsRe` options.\n    + **audit** - Must use with `targetText` and `replacementText`. Outputs lines found and the change plus any files that would be omitted. Tests `includeExts`, `excludeDirsRe`, `targetText` and `replacementText` options.\n    + **update** - Does the actual update on the files in place. Use only if you have version control.\n  + **includeExts** - {Array} File extensions used to include files in processing. Must include the dot.\n  + **excludeDirsRe** - {RegExp} A regular expression used to exclude directories from processing. A match is an exclusion.\n  + **targetText** - {String|RegExp} Used to identify the line to process. First argument to `string.replace`.\n  + **replacementText** - {String|Function} Used to replace the `targetText`. Second argument to `string.replace`.\n  + **replacementFilter** - {Function} A function to deny a specific replacement otherwise matched by `targetText`. Return true to allow the replacement to proceed as normal, false to deny it. If not supplied, defaults to all matched replacements allowed.  \n    *signature:* **function (filePath, lineText): Boolean**  \n  + **logger** - {Function} A log function to receive output. Defaults to `console.log`.\n\n\n## Example Usage\n```javascript\n// Example use for a copyright banner text update:\nimport picklr from 'picklr';\n\n// Output what files WOULD be affected by includes/excludes:\npicklr('.', {\n  action: 'echo',\n  includeExts: ['.js', '.jsx', '.scss'],\n  excludeDirsRe: /\\/\\.|node_modules|dist|tmp|reports/i\n});\n\n// Output what WOULD be processed using targetText/replacementText:\npicklr('.', {\n  action: 'audit',\n  targetText: 'Copyright (c) 2015',\n  replacementText: 'Copyright (c) 2015, 2016',\n  includeExts: ['.js', '.jsx', '.scss'],\n  excludeDirsRe: /\\/\\.|node_modules|dist|tmp|reports/i\n});\n\n// Got it. Now, actually perform the pick line and replacement.\npicklr('.', {\n  action: 'update',\n  targetText: 'Copyright (c) 2015',\n  replacementText: 'Copyright (c) 2015, 2016',\n  includeExts: ['.js', '.jsx', '.scss'],\n  excludeDirsRe: /\\/\\.|node_modules|dist|tmp|reports/i\n});\n```\n\n### Non-module Usage\n```javascript\n// import the es module in a non-module environment, echo options example:\nimport('picklr').then(({ picklr }) =\u003e {\n  picklr('.', {\n    action: 'echo',\n    includeExts: ['.js', '.jsx', '.scss'],\n    excludeDirsRe: /\\/\\.|node_modules|dist|tmp|reports/i\n  });\n});\n```\n\n### Omitted\nTo see only what files would be omitted, set your picklr script to use action 'audit', then grep the output for 'Omitted'.\n```javascript\n// myPicklrScript.js\n\nimport picklr from 'picklr';\npicklr('.', {\n  action: 'audit',\n  targetText: 'Copyright (c) 2015',\n  replacementText: 'Copyright (c) 2015, 2016',\n  includeExts: ['.js', '.jsx', '.scss'],\n  excludeDirsRe: /\\/\\.|node_modules|dist|tmp|reports/i\n});\n```\n```shell\nnode myPicklrScript.js | grep 'Omitted'\n```\n\n## License\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalnerve%2Fpicklr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalnerve%2Fpicklr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalnerve%2Fpicklr/lists"}