{"id":20393039,"url":"https://github.com/aichbauer/node-template-dir","last_synced_at":"2026-04-21T05:35:09.210Z","repository":{"id":57376671,"uuid":"103563598","full_name":"aichbauer/node-template-dir","owner":"aichbauer","description":"Copies files and folders from source directory to destination directory (all directories recursively or just files from the source directory) with template style from template-file","archived":false,"fork":false,"pushed_at":"2017-09-19T21:52:31.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-22T03:03:39.215Z","etag":null,"topics":["copy","dir","directory","file","nodejs","recursive","templat-file","template","template-dir"],"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/aichbauer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-14T17:48:14.000Z","updated_at":"2023-08-24T20:35:03.000Z","dependencies_parsed_at":"2022-08-29T19:11:14.510Z","dependency_job_id":null,"html_url":"https://github.com/aichbauer/node-template-dir","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/aichbauer/node-template-dir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-template-dir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-template-dir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-template-dir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-template-dir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aichbauer","download_url":"https://codeload.github.com/aichbauer/node-template-dir/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-template-dir/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266424024,"owners_count":23926124,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["copy","dir","directory","file","nodejs","recursive","templat-file","template","template-dir"],"created_at":"2024-11-15T03:47:06.818Z","updated_at":"2026-04-21T05:35:04.166Z","avatar_url":"https://github.com/aichbauer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# template-dir\n\n\u003e Copies files and folders from source directory to destination directory (all directories recursively or just files from the source directory) with template style from [template-file](https://github.com/gsandf/template-file#readme)\n\n[![Build Status](https://travis-ci.org/aichbauer/node-template-dir.svg?branch=master)](https://travis-ci.org/aichbauer/node-template-dir)\n[![Build status](https://ci.appveyor.com/api/projects/status/6xmc4f007uoacpcl?svg=true)](https://ci.appveyor.com/project/aichbauer/node-template-dir)\n[![Coverage Status](https://coveralls.io/repos/github/aichbauer/node-template-dir/badge.svg?branch=master)](https://coveralls.io/github/aichbauer/node-template-dir?branch=master)\n\n## Installation\n\n```sh\n$ npm i template-dir --save\n```\n\nor\n\n```sh\n$ yarn add template-dir\n```\n\n## Usage\n\nIn this section you will see two example usages. [One example](#example-one) copies the complete source directory tree to the destination and replaces all variables within the templates. [The other example](#example-two) will only copy files within the source directory to the destination directory and replaces all variables within the templates.\n\nThe given source directory tree:\n\n```\n.\n+-- source/directory/\n    |\n    +-- dir-1\n    |   |\n    |   +-- file-2\n    |\n    +-- dir-2\n    |   |\n    |   +-- file-3\n    |\n    +-- template-1\n```\n\nThe given `template-1`:\n\n```txt\nMy name is {{name}} and I am {{age}} years old.\n```\n\n### example one\n\nThe `template-dir` module example **WITH** copying recursive all files and directories:\n\n```js\nconst templateDir = require('template-dir'); // import templateDir from 'template-dir';\n\n// if we set onlyFiles to false it copies the complete directory tree\n// from 'source/directory' to 'destination/directory'\n// excluding 'dir-1'\ntemplateDir(\n  {\n    source: 'source/directory', \n    destination: 'destination/directory',\n    onlyFiles: false,\n    exclude: ['dir-1'], // add as many directories as you want to the array\n  },\n  {\n    name: 'Lukas',\n    age: '25',\n  },\n);\n```\n\nThe example above will copy the source directory tree to the 'destination/directory' and replace all variables within all files\n\nThe destination directory tree: \n\n```\n.\n+-- destination/directory/\n    |\n    +-- dir-2\n    |   |\n    |   +-- file-3\n    |\n    +-- template-1\n```\n\nThe template-1 with filled variables:\n\n```txt\nMy name is Lukas and I am 25 years old.\n```\n\n### example two\n\nThe `template-dir` module example **WITHOUT** copying recursive all files and directories:\n\n```js\nconst templateDir = require('template-dir'); // import templateDir from 'template-dir';\n\n// if we set onlyFiles to true it copies only the files\n// within 'source/directory' to 'destination/directory'\ntemplateDir(\n  {\n    source: 'source/directory', \n    destination: 'destination/directory',\n    onlyFiles: true\n  },\n  {\n    name: 'Lukas',\n    age: '25',\n  },\n);\n```\n\nThe example above will only copy the files within the source directory and will not recursively copy all directories and files.\n\nThe destination directory tree: \n\n```\n.\n+-- destination/directory/\n    |\n    +-- template-1\n```\n\nThe template-1 with filled variables:\n\n```txt\nMy name is Lukas and I am 25 years old.\n```\n\n## LICENSE\n\nMIT © Lukas Aichbauer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichbauer%2Fnode-template-dir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faichbauer%2Fnode-template-dir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichbauer%2Fnode-template-dir/lists"}