{"id":21339871,"url":"https://github.com/webextensions/copy-files-from-to","last_synced_at":"2025-10-29T11:04:28.839Z","repository":{"id":45963672,"uuid":"90858440","full_name":"webextensions/copy-files-from-to","owner":"webextensions","description":"Copy files from one path to another, based on the instructions provided in a configuration file.","archived":false,"fork":false,"pushed_at":"2025-10-27T18:17:55.000Z","size":776,"stargazers_count":49,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-27T18:33:48.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/copy-files-from-to","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/webextensions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-10T11:49:57.000Z","updated_at":"2025-10-27T18:17:58.000Z","dependencies_parsed_at":"2023-11-22T20:27:27.205Z","dependency_job_id":"1453ece1-3a0a-47f2-8101-91acb36e7359","html_url":"https://github.com/webextensions/copy-files-from-to","commit_stats":{"total_commits":124,"total_committers":8,"mean_commits":15.5,"dds":"0.33870967741935487","last_synced_commit":"e16eec12f0168073a08360a594a5125a769ff2a4"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/webextensions/copy-files-from-to","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webextensions%2Fcopy-files-from-to","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webextensions%2Fcopy-files-from-to/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webextensions%2Fcopy-files-from-to/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webextensions%2Fcopy-files-from-to/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webextensions","download_url":"https://codeload.github.com/webextensions/copy-files-from-to/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webextensions%2Fcopy-files-from-to/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281608588,"owners_count":26530372,"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-10-29T02:00:06.901Z","response_time":59,"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":[],"created_at":"2024-11-22T00:47:50.454Z","updated_at":"2025-10-29T11:04:28.827Z","avatar_url":"https://github.com/webextensions.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# copy-files-from-to\nCopy files from one path to another, based on the instructions provided in a configuration file.\n\n# Use cases\n\n* This tool is useful when a few files need to be copied / updated frequently\n* This tool works as a basic alternative for `npm` / `bower` when you wish to copy the scripts out of `node_modules` / `bower_components` folder\n* You may like to use this tool if you prefer to keep some third-party dependencies (eg: from `node_modules`) updated and/or committed to your project's repository\n\n\n# Installation\n```sh\n$ npm install -g copy-files-from-to\n```\n\n# How to use\nIn your `package.json` file, add the `\"copyFiles\"` and `\"copyFilesSettings\"` (optional) instructions as described in this section.\n\nAlternatively, you may create a file, say, `copy-files-from-to.json` or `copy-files-from-to.cjson` [(JSON with comments)](https://github.com/kof/node-cjson) in your project and refer to the following usage examples.\n\n## Basic usage\nSample file: [package.json](test/test-copy-instructions-from-package-json/package.json)\n```json\n{\n    \"name\": \"my-application\",\n    \"version\": \"1.0.0\",\n    \"dependencies\": {\n        \"jquery\": \"3.4.0\"\n    },\n    \"copyFiles\": [\n        {\n            \"from\": \"node_modules/jquery/dist/jquery.js\",\n            \"to\": \"scripts/jquery/jquery.js\"\n        },\n        {\n            \"from\": \"https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js\",\n            \"to\": \"scripts/console-panel/console-panel.js\"\n        },\n        {\n            \"from\": \"https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.css\",\n            \"to\": \"scripts/console-panel/console-panel.css\"\n        }\n    ]\n}\n```\n\nSample file: [copy-files-from-to.json](test/basic-usage/copy-files-from-to.json)\n```json\n{\n    \"copyFiles\": [\n        {\n            \"from\": \"node_modules/jquery/dist/jquery.js\",\n            \"to\": \"scripts/jquery/jquery.js\"\n        },\n        {\n            \"from\": \"https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js\",\n            \"to\": \"scripts/console-panel/console-panel.js\"\n        },\n        {\n            \"from\": \"https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.css\",\n            \"to\": \"scripts/console-panel/console-panel.css\"\n        }\n    ]\n}\n```\n\n### Command and output\n```\n$ copy-files-from-to\n```\n\n```\nReading copy instructions from file copy-files-from-to.json\n\nStarting copy operation in \"default\" mode:\n ✔ Copied [ utf8 ] node_modules/jquery/dist/jquery.js to scripts/jquery/jquery.js\n ✔ Copied [binary] assets/logo.png to build/logo.png\n ✔ Copied [remote] https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.css to scripts/console-panel/console-panel.css\n ✔ Copied [remote] https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js to scripts/console-panel/console-panel.js\n```\n\n\n## Advanced usage\nSample file: [copy-files-from-to.cjson](test/advanced-usage/copy-files-from-to.cjson)\n```js\n// This is a CJSON file (JSON with comments)\n{\n    \"copyFiles\": [\n        // In \"development\" mode, copy from the full version of the library, in all other modes, use the minified version\n        {\n            \"from\": {\n                \"default\": \"https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js\",\n                \"development\": \"https://raw.githubusercontent.com/jashkenas/underscore/master/underscore.js\"\n            },\n            \"to\": \"scripts/underscore.js\"\n        },\n\n        // Copy this file only in \"pre-production\" mode\n        {\n            \"from\": \"https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js.map\",\n            \"to\": {\n                \"default\": {\n                    \"skip\": true\n                },\n                \"pre-production\": \"scripts/underscore.js.map\"\n            }\n        },\n\n        // Copy this file in \"pre-production\" and \"production\" mode only\n        {\n            \"from\": {\n                \"default\": {\n                    \"skip\": true\n                },\n                \"pre-production\": \"node_modules/native-promise-only/npo.js\",\n                \"production\": \"node_modules/native-promise-only/npo.js\"\n            },\n            \"to\": \"scripts/native-promise-only.js\"\n        },\n\n        // Copy this file in all modes except \"production\" mode\n        {\n            \"from\": \"https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js\",\n            \"to\": {\n                \"default\": \"scripts/console-panel/console-panel.js\",\n                \"production\": {\n                    \"skip\": true\n                }\n            }\n        },\n\n        // Copy the contents of the directory \"src/app/images\" to \"public/assets\"\n        {\n            \"from\": \"src/app/images\",\n            \"to\": \"public/assets\"\n        },\n\n        // Copy the file at the mentioned path into the target directory\n        {\n            \"from\": \"src/app/images/favicon.ico\",\n            \"to\": \"public/\"\n        },\n\n        // Copy the files matching the \"glob\" pattern (matching files, along with the their folder structure go into the \"to\" directory)\n        {\n            \"from\": \"assets/**/*.jpg\",\n            \"to\": \"public/images/\"\n        },\n\n        // Copy the files matching the \"glob\" pattern (all of the matching files directly go into the \"to\" directory) since \"toFlat\" is set to \"true\"\n        {\n            \"from\": \"assets/**/*.jpg\",\n            \"to\": \"public/copy-all-jpg-files-to-this-directory/\",\n            \"toFlat\": true\n        }\n    ],\n    \"copyFilesSettings\": {\n        \"whenFileExists\": \"notify-about-available-change\",\n        \"addReferenceToSourceOfOrigin\": false,\n        \"ignoreDotFilesAndFolders\": true,\n        \"removeSourceMappingURL\": false,\n        \"minifyJs\": true,          // via https://www.npmjs.com/package/terser\n        \"minifyJsTerserOptions\": { // Reference: https://terser.org/docs/options/\n            // Default options if \"minifyJsTerserOptions\" is not set\n            \"compress\": {\n                \"sequences\": false\n            },\n            \"mangle\": false,\n            \"format\": {\n                \"semicolons\": false\n            }\n        }\n    }\n}\n```\n\n### Command and output\n\n\u003cdetails\u003e\n  \u003csummary\u003e$ copy-files-from-to\u003c/summary\u003e\n  \u003cp\u003e\n\n  ```\n  Reading copy instructions from file copy-files-from-to.cjson\n\n  Starting copy operation in \"default\" mode:\n   ✔ Copied [remote] https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js to scripts/underscore.js\n   ✔ Copied [remote] https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js to scripts/console-panel/console-panel.js\n  ```\n  \u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e$ copy-files-from-to --mode development\u003c/summary\u003e\n  \u003cp\u003e\n\n  ```\n  Reading copy instructions from file copy-files-from-to.cjson\n\n  Starting copy operation in \"development\" mode:\n   ✔ Copied [remote] https://raw.githubusercontent.com/jashkenas/underscore/master/underscore.js to scripts/underscore.js\n   ✔ Copied [remote] https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js to scripts/console-panel/console-panel.js\n  ```\n  \u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e$ copy-files-from-to --mode production\u003c/summary\u003e\n  \u003cp\u003e\n\n  ```\n  Reading copy instructions from file copy-files-from-to.cjson\n\n  Starting copy operation in \"production\" mode:\n   ✔ Copied [ utf8 ] node_modules/native-promise-only/npo.js to scripts/native-promise-only.js\n   ✔ Copied [remote] https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js to scripts/underscore.js\n  ```\n  \u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e$ copy-files-from-to --mode pre-production --config copy-files-from-to.cjson\u003c/summary\u003e\n  \u003cp\u003e\n\n  ```\n  Reading copy instructions from file copy-files-from-to.cjson\n\n  Starting copy operation in \"pre-production\" mode:\n   ✔ Copied [ utf8 ] node_modules/native-promise-only/npo.js to scripts/native-promise-only.js\n   ✔ Copied [remote] https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js to scripts/underscore.js\n   ✔ Copied [remote] https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js.map to scripts/underscore.js.map\n   ✔ Copied [remote] https://raw.githubusercontent.com/webextensions/console-panel/master/src/console-panel.js to scripts/console-panel/console-panel.js\n  ```\n  \u003c/p\u003e\n\u003c/details\u003e\n\n# Configuration\n\n## Structure of \"copyFiles\" instruction file\n* You can provide the \"copyFiles\" instructions in a JSON or [CJSON](https://github.com/kof/node-cjson) file\n* The file can be structured like:\n    ```js\n    {\n        // copyFiles (required parameter)\n        //     Summary: This is the instruction set for the files to be copied\n        //     Data type: array (of objects)\n        \"copyFiles\": [\n            // Using \"from\" and \"to\", both, as simple strings\n            {\n                // from (required parameter)\n                //     Summary: This contains the path of a file which is either on disk or accessible via \"http\"/\"https\" URL\n                //     Data type: string, array, or object\n                //     Note: When it is set as a string, it would be used for all modes. When it is set as an object, it can be\n                //           configured differently for different modes (refer to the next example)\n                //           When it is set as an array, it describes an array of glob patterns and settings\n                \"from\": \"http://example.com/index.html\",\n\n                // to (required parameter)\n                //     Data type: string or object\n                //     Summary: This instruction set would write a file to this path on the disk\n                //     Note: When it is set as a string, it would be used for all modes. When it is set as an object, it can be\n                //           configured differently for different modes\n                \"to\": \"example-index.html\"\n            },\n\n            // Using \"from\" as an array of glob expressions\n            {\n                // from (required parameter)\n                //     Data type: array\n                //     Note: When it is set as an array, it describes an array of glob patterns and settings\n                //           Any strings in the array are used as glob patterns.\n                //           Any objects are used as fast-glob options: (See https://www.npmjs.com/package/fast-glob)\n                \"from\": [\n                    // The first entry here is also used to figure out the \"non-magic parent path\" from a glob string\n                    // Copy all files from the public folder\n                    \"public/**/*\",\n                    // A \"!\" at the beginning of the pattern will ignore any files matching that pattern\n                    // This ignores all files in the public/tmp folder\n                    \"!public/tmp/**/*\",\n                    // Any objects in the array will be collected together to pass to fast-glob as options\n                    // This will copy any files starting with a .*\n                    // This will not copy symlinked folders\n                    { dot: true, followSymlinkedDirectories: false }\n                ],\n                // to (required parameter)\n                //     Data type: string\n                //     Summary: This instruction set would write all the files found with the glob patterns and settings\n                //     to this folder.\n                //     Note: When using glob patterns for the \"from\" value the target \"to\" path needs to be a folder\n                \"to\": \"build/\"\n            },\n\n            // Using \"from\" and \"to\", both, as objects (and use string based mode entries)\n            {\n                \"from\": {\n                    // The \"from\" section should contain details about at least one mode\n\n                    // \"default\" mode (optional parameter, recommended to have)\n                    //     Summary: \"default\" mode would be used when the command is executed without any mode or when the command\n                    //              is executed in a mode which is not described for the given entry\n                    //     Data type: string or object\n                    \"default\": \"node_modules/example/index.js\",\n\n                    // \u003ccustom\u003e mode (optional parameter if any other mode exists)\n                    \"development\": \"node_modules/example/dev.js\",\n\n                    // \u003ccustom\u003e mode (optional parameter if any other mode exists)\n                    \"production\": \"node_modules/example/production.js\"\n\n                    // More \u003ccustom\u003e mode entries\n                },\n                \"to\": {\n                    \"default\": \"example.js\"\n                }\n            },\n\n            // Using \"from\" and \"to\", both, as objects (and use object based mode entries)\n            {\n                \"from\": {\n                    \"default\": {\n                        // src (required parameter)\n                        //     Summary: This contains the path of a file which is either on disk or accessible via \"http\"/\"https\" URL\n                        //     Data type: string\n                        \"src\": \"http://example.com/index-1.0.0.js.map\",\n\n                        // latest (optional parameter)\n                        //     Summary: This contains the path of a file which is either on disk or accessible via \"http\"/\"https\" URL\n                        //     Data type: string\n                        //     Note: When this tools is executed with \"--outdated\" parameter, then the file from \"latest\" would be\n                        //           compared with the file from \"src\", and if there are any differences, it would be notified that\n                        //           an update is available\n                        \"latest\": \"http://example.com/index.js.map\"\n                    }\n                },\n                \"to\": {\n                    \"default\": {\n                        // dest (required parameter, when not using \"skip\" parameter set as true)\n                        //     Summary: This instruction set would write a file to this path on the disk\n                        //     Data type: string\n                        \"dest\": \"scripts/index.js.map\",\n\n                        // removeSourceMappingURL (optional parameter)\n                        //     Summary: When set to true, any contents after \"//# sourceMappingURL=\" would be removed before\n                        //              the copy operation\n                        //     Data type: boolean\n                        //     Default value: false\n                        \"removeSourceMappingURL\": false,\n\n                        // minifyJs (optional parameter)\n                        //     Summary: When set to true, this JavaScript file would be minified before the copy operation\n                        //              (via https://www.npmjs.com/package/terser)\n                        //     Data type: boolean\n                        //     Default value: undefined\n                        \"minifyJs\": false\n                    },\n                    \"production\": {\n                        // skip (required parameter, when not using \"dest\" parameter)\n                        //     Summary: If you wish to skip a file in some particular mode, add \"skip\" as true, otherwise a warning\n                        //              would be raised when you run this tool for that particular mode\n                        //     Data type: boolean\n                        //     Default value: false\n                        \"skip\": true\n                    }\n                }\n            }\n\n            // Add more object entries with \"from\" and \"to\" details, and you can use any of the supported data types to\n            // represent the values of \"from\", \"to\" and their \"default\" or \u003ccustom\u003e modes\n        ],\n\n        // copyFilesSettings (optional parameter)\n        //     Summary: Settings for the copy files operation\n        //     Data type: object\n        \"copyFilesSettings\": {\n            // whenFileExists (optional parameter)\n            //     Summary: When the file at \"to\" path already exists, what action should be taken\n            //     Data type: string\n            //     Supported values: \"do-nothing\" / \"overwrite\" / \"notify-about-available-change\"\n            //     Default value: \"do-nothing\"\n            \"whenFileExists\": \"notify-about-available-change\",\n\n            // addReferenceToSourceOfOrigin (optional parameter)\n            //     Summary: When set to true, the copy operation would create a file \"\u003cto-file-path\u003e.source.txt\"\n            //              which would contain a link to the \"from\" path\n            //     Data type: boolean\n            //     Default value: false\n            \"addReferenceToSourceOfOrigin\": false\n\n            // ignoreDotFilesAndFolders (optional parameter)\n            //     Summary: When set to true, globbing will ignore files and folders starting with a \".\" dot.\n            //     Data type: boolean\n            //     Default value: false\n            \"ignoreDotFilesAndFolders\": true\n\n            // removeSourceMappingURL (optional parameter)\n            //     Summary: When set to true, any contents after \"//# sourceMappingURL=\" would be removed before\n            //              the copy operation\n            //     Data type: boolean\n            //     Default value: false\n            \"removeSourceMappingURL\": false,\n\n            // minifyJs (optional parameter)\n            //     Summary: When set to true, the JavaScript files would be uglified before the copy operation\n            //              (via https://www.npmjs.com/package/terser)\n            //     Data type: boolean\n            //     Default value: false\n            \"minifyJs\": true,\n\n            // minifyJsTerserOptions (optional parameter)\n            //     Summary: Options for the terser minification operation\n            //     Data type: object\n            //     Default value: \u003cas-specified-below\u003e\n            //     Reference: https://terser.org/docs/options/\n            \"minifyJsTerserOptions\": {\n                // Default options if \"minifyJsTerserOptions\" is not set\n                // Note: By default, only license information is preserved in \"comments\" (via a custom function defintion), set `minifyJsTerserOptions.format.comments` to `null` or an appropriate value to override that\n                \"compress\": {\n                    \"sequences\": false\n                },\n                \"mangle\": false,\n                \"format\": {\n                    \"semicolons\": false\n                }\n            }\n        }\n    }\n    ```\n\n## Command line options\n\n```sh\n$ copy-files-from-to --help\n```\n\n```\nUsage:\n  copy-files-from-to [--config \u003cconfig-file\u003e] [--mode \u003cmode-name\u003e] [...]\n\nExamples:\n  copy-files-from-to\n  copy-files-from-to --config copy-files-from-to.json\n  copy-files-from-to --mode production\n  copy-files-from-to -h\n  copy-files-from-to --version\n\nOptions:\n     --config \u003cconfig-file-path\u003e     Path to configuration file\n                                     When unspecified, it looks for:\n                                         1) copy-files-from-to.cjson\n                                         2) copy-files-from-to.json\n                                         3) package.json\n     --mode \u003cmode-name\u003e              Mode to use for copying the files\n                                     When unspecified, it uses \"default\" mode\n     --when-file-exists \u003coperation\u003e  Override \"whenFileExists\" setting specified in configuration file\n                                     \u003coperation\u003e can be \"notify-about-available-change\" or \"overwrite\" or \"do-nothing\"\n     --outdated                      Notify about outdated parts of the configuration file\n                                     (takes cue from \"latest\" property, wherever specified)\n     --verbose                       Verbose logging\n     --silent                        Reduced logging (log only warnings and errors)\n  -v --version                       Output the version number\n  -h --help                          Show help\n```\n\n# TODO\n\nSee [TODO.md](TODO.md)\n\n\n# About this project\n\n## Author\n\n* Priyank Parashar - [GitHub](https://github.com/paras20xx) | [Twitter](https://twitter.com/paras20xx) | [LinkedIn](https://linkedin.com/in/ParasharPriyank/)\n\n## Connect with us\n\n* https://www.webextensions.org/\n* [GitHub](https://github.com/webextensions/live-css-editor)\n* [Twitter](https://twitter.com/webextensions)\n\n## License\n\n* [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebextensions%2Fcopy-files-from-to","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebextensions%2Fcopy-files-from-to","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebextensions%2Fcopy-files-from-to/lists"}