{"id":22897271,"url":"https://github.com/center-key/copy-file-util","last_synced_at":"2025-09-02T13:39:21.730Z","repository":{"id":59859002,"uuid":"539712664","full_name":"center-key/copy-file-util","owner":"center-key","description":"📄 Copy or rename a file (CLI for package.json scripts)","archived":false,"fork":false,"pushed_at":"2025-07-13T06:53:54.000Z","size":310,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T12:59:36.277Z","etag":null,"topics":["cli","copy","cp","file","rename","scripts"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/center-key.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2022-09-21T22:51:19.000Z","updated_at":"2025-07-13T06:53:57.000Z","dependencies_parsed_at":"2024-04-18T12:47:09.018Z","dependency_job_id":"c1467b3f-14cc-4d81-9740-b36b0273b9d8","html_url":"https://github.com/center-key/copy-file-util","commit_stats":{"total_commits":58,"total_committers":1,"mean_commits":58.0,"dds":0.0,"last_synced_commit":"130df0cb1a143b5f936ed84e5a28af323144dd00"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/center-key/copy-file-util","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fcopy-file-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fcopy-file-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fcopy-file-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fcopy-file-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/center-key","download_url":"https://codeload.github.com/center-key/copy-file-util/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fcopy-file-util/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273293517,"owners_count":25079880,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","copy","cp","file","rename","scripts"],"created_at":"2024-12-14T00:16:23.941Z","updated_at":"2025-09-02T13:39:21.682Z","avatar_url":"https://github.com/center-key.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# copy-file-util\n\u003cimg src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo\u003e\n\n_Copy or rename a file with optional package version number (CLI tool designed for use in npm package.json scripts)_\n\n[![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/copy-file-util/blob/main/LICENSE.txt)\n[![npm](https://img.shields.io/npm/v/copy-file-util.svg)](https://www.npmjs.com/package/copy-file-util)\n[![Build](https://github.com/center-key/copy-file-util/actions/workflows/run-spec-on-push.yaml/badge.svg)](https://github.com/center-key/copy-file-util/actions/workflows/run-spec-on-push.yaml)\n\n**copy-file-util** takes a source file and copies it to a new destination.\u0026nbsp;\nThe command's console output includes a timestamp and formatting helpful in build systems.\n\n\u003cimg src=https://raw.githubusercontent.com/center-key/copy-file-util/main/screenshot.png\nwidth=800 alt=screenshot\u003e\n\n## A) Setup\nInstall package for node:\n```shell\n$ npm install --save-dev copy-file-util\n```\n\n## B) Usage\n### 1. npm package.json scripts\nRun `copy-file` from the `\"scripts\"` section of your **package.json** file.\n\nParameters:\n* The **first** parameter is the *source* file.\n* The **second** parameter is the *target* file or folder (use the `--folder` flag).\n\nExample **package.json** scripts:\n```json\n   \"scripts\": {\n      \"pub-license\": \"copy-file src/LICENSE doc/license.txt\",\n      \"backup-license\": \"copy-file src/LICENSE --folder backup\",\n   },\n```\n\n### 2. Command-line npx\nExample terminal commands:\n```shell\n$ npm install --save-dev copy-file-util\n$ copy-file src/web/api.html docs/api-manual.html\n```\nYou can also install **copy-file-util** globally (`--global`) and then run it anywhere directly from the terminal.\n\n### 3. CLI flags\nCommand-line flags:\n| Flag             | Description                                      | Values     |\n| ---------------- | ------------------------------------------------ | ---------- |\n| `--cd`           | Change working directory before starting copy.   | **string** |\n| `--folder`       | Indicates the target is a folder.                | N/A        |\n| `--move`         | Delete the source file after copying it.         | N/A        |\n| `--no-overwrite` | Abort if target file already exists.             | N/A        |\n| `--note`         | Place to add a comment only for humans.          | **string** |\n| `--platform-eol` | Save target file with OS dependent line endings. | N/A        |\n| `--quiet`        | Suppress informational messages.                 | N/A        |\n\nExamples:\n   - `copy-file app.js app.mjs --quiet`\u003cbr\u003e\n   Displays no output.\n\n   - `copy-file app.js --folder dist`\u003cbr\u003e\n   Copies **app.js** into the **dist** folder.\n\n   - `copy-file 'src/Legal Notice.md' --folder dist`\u003cbr\u003e\n   Copies a file that has a space in its filename.\n\n   - `copy-file node_modules/ui-xlib/colors.less --folder src/css --platform-eol`\u003cbr\u003e\n   Copies `colors.less` into your project and converts the file's EOL characters to `\\n` for LF\n   on Unix and `\\r\\n` for CRLF on Windows.\n\n   - `copy-file app.js --move --folder dist`\u003cbr\u003e\n   Like the `mv` Unix command.\n\n   - `copy-file default-config.json settings/config.json --no-overwrite`\u003cbr\u003e\n   Performs a safe copy that aborts if the **settings/config.json** file already exists.\n\n_**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._\n\n### 4. Template variables\nThe *target* parameter can contain template variables, like `{{package.version}}` and `{{package.name}}`, which will be replaced with values with values from your project's **package.json** file.\n\nExample:\n   - `copy-file build/app.js dist/app-v{{package.version}}.js`\u003cbr\u003e\n   Creates a copy of **app.js** named something like **app-v1.2.3.js** based on the version of your project.\n\n## C) Application Code\nEven though **copy-file-util** is primarily intended for build scripts, the package can be used programmatically in ESM and TypeScript projects.\n\nExample:\n``` typescript\nimport { copyFile } from 'copy-file-util';\n\nconst result = copyFile.cp('src/web/api.html' { targetFile: 'docs/api-manual.html' });\nconsole.info('Execution time:', result.duration, 'ms');\n```\n\nSee the **TypeScript Declarations** at the top of [copy-file.ts](src/copy-file.ts) for documentation.\n\n\u003cbr\u003e\n\n---\n**CLI Build Tools for package.json**\n   - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):\u0026nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_\n   - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):\u0026nbsp; _Copy or rename a file with optional package version number_\n   - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):\u0026nbsp; _Recursively copy files from one folder to another folder_\n   - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):\u0026nbsp; _Run a command on each file in a folder and its subfolders_\n   - 🔍 [replacer-util](https://github.com/center-key/replacer-util):\u0026nbsp; _Find and replace strings or template outputs in text files_\n   - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):\u0026nbsp; _Revision web asset filenames with cache busting content hash fingerprints_\n   - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):\u0026nbsp; _Organize npm package.json scripts into groups of easy to manage commands_\n   - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):\u0026nbsp; _Check the markup validity of HTML files using the W3C validator_\n\nFeel free to submit questions at:\u003cbr\u003e\n[github.com/center-key/copy-file-util/issues](https://github.com/center-key/copy-file-util/issues)\n\n[MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenter-key%2Fcopy-file-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcenter-key%2Fcopy-file-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenter-key%2Fcopy-file-util/lists"}