{"id":22273101,"url":"https://github.com/mac-/grunt-hash-files","last_synced_at":"2025-03-25T16:27:05.156Z","repository":{"id":13797975,"uuid":"16493518","full_name":"mac-/grunt-hash-files","owner":"mac-","description":"A grunt plugin for copying all specified files to a directory that includes a hash of the contents of those files","archived":false,"fork":false,"pushed_at":"2014-04-08T16:23:42.000Z","size":180,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T14:41:00.837Z","etag":null,"topics":[],"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/mac-.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}},"created_at":"2014-02-03T21:27:00.000Z","updated_at":"2015-06-28T14:59:09.000Z","dependencies_parsed_at":"2022-09-26T19:43:27.555Z","dependency_job_id":null,"html_url":"https://github.com/mac-/grunt-hash-files","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac-%2Fgrunt-hash-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac-%2Fgrunt-hash-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac-%2Fgrunt-hash-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mac-%2Fgrunt-hash-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mac-","download_url":"https://codeload.github.com/mac-/grunt-hash-files/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245498984,"owners_count":20625284,"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-12-03T13:09:46.317Z","updated_at":"2025-03-25T16:27:05.120Z","avatar_url":"https://github.com/mac-.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-hash-files\n\n\u003e Copies files to a directory that includes a hash of the contents of those files. This is useful for versioning the contents of a folder.\n\n## Getting Started\nThis plugin requires Grunt `~0.4.2`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-hash-files --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-hash-files');\n```\n\n## The \"hash_files\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `hash_files` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n\thash_files: {\n\t\toptions: {\n\t\t\t// Task-specific options go here.\n\t\t},\n\t\tyour_target: {\n\t\t\t// Target-specific file lists and/or options go here.\n\t\t},\n\t},\n});\n```\n\n### Options\n\n#### algorithm\nType: `String`\nDefault value: `\"sha1\"`\n\nA string value that is the type of hashing algorithm to use. Must be either \"sha1\" or \"md5\".\n\n#### numChars\nType: `Number`\nDefault value: `undefined`\n\nThe number of characters from the beginning of the hash value to use. When set to undefined, all characters are used.\n\n#### token\nType: `String`\nDefault value: `\"{hash}\"`\n\nThe string used as a token for where the actual hash value should be replaced.\n\n#### encoding\nType: `String`  \nDefault: `grunt.file.defaultEncoding`\n\nThe file encoding to copy files with.\n\n#### mode\nType: `Boolean` or `Number`  \nDefault: `false`\n\nWhether to copy or set the existing file permissions. Set to `true` to copy the existing file permissions. Or set to the mode, i.e.: `0644`, that copied files will be set to.\n\n\n### Usage Examples\n\n#### Default Options\nIn this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the files would be copied to the following directory: `dest/41c45d195416ad480be844112c8e596ac367628c/`\n\n```js\ngrunt.initConfig({\n\thash_files: {\n\t\toptions: {},\n\t\tfiles: {\n\t\t\t'dest/{hash}/': ['src/testing', 'src/123'],\n\t\t},\n\t},\n});\n```\n\n\n#### Custom Options\nIn this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the files would be copied to the following directory: `dest/236a956/`\n\n```js\ngrunt.initConfig({\n\thash_files: {\n\t\toptions: {\n\t\t\talgorithm: 'md5',\n\t\t\tnumChars: 7,\n\t\t\ttoken: '\\\u003ctoken\\\u003e'\n\t\t},\n\t\tfiles: {\n\t\t\t'dest/\u003ctoken\u003e/': ['src/testing', 'src/123'],\n\t\t},\n\t},\n});\n```\n\n\nHere are some additional examples, given the following file tree:\n```shell\n$ tree -I node_modules\n.\n├── Gruntfile.js\n└── src\n    ├── a\n    └── subdir\n        └── b\n\n2 directories, 3 files\n```\n\n**Copy a single file tree:**\n```js\nhash_files: {\n\tmain: {\n\t\tsrc: 'src/*',\n\t\tdest: '{hash}/'\n\t}\n},\n```\n\n```shell\n$ grunt hash-files\nRunning \"hash_files:main\" (hash_files) task\nCreated 1 directories, copied 1 files\n\nDone, without errors.\n$ tree -I node_modules\n.\n├── Gruntfile.js\n├── bdb72f90802abc542e79d0e6eb809d7ed71b0f00\n│   └── src\n│       ├── a\n│       └── subdir\n└── src\n    ├── a\n    └── subdir\n        └── b\n\n5 directories, 4 files\n```\n\n**Flattening the filepath output:**\n\n```js\nhash_files: {\n\toptions: {\n\t\tnumChars: 8,\n\t\talgorithm: 'md5'\n\t},\n\tmain: {\n\t\texpand: true,\n\t\tcwd: 'src/',\n\t\tsrc: '**',\n\t\tdest: '{hash}/',\n\t\tflatten: true,\n\t\tfilter: 'isFile'\n\t}\n},\n```\n\n```shell\n$ grunt hash_files\nRunning \"hash_files:main\" (hash_files) task\nCopied 2 files\n\nDone, without errors.\n$ tree -I node_modules\n.\n├── Gruntfile.js\n├── 6a003f0e\n│   ├── a\n│   └── b\n└── src\n    ├── a\n    └── subdir\n        └── b\n\n3 directories, 5 files\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmac-%2Fgrunt-hash-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmac-%2Fgrunt-hash-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmac-%2Fgrunt-hash-files/lists"}