{"id":19330640,"url":"https://github.com/eridem/hostify","last_synced_at":"2026-04-09T20:03:20.428Z","repository":{"id":57266737,"uuid":"82474582","full_name":"eridem/hostify","owner":"eridem","description":"CLI tool and utils for hosts files: /etc/hosts and C:\\Windows\\System32\\drivers\\etc\\hosts","archived":false,"fork":false,"pushed_at":"2017-02-25T15:01:28.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T08:20:57.919Z","etag":null,"topics":["cli","hosts","ip","javascript","linux","macos","nodejs","windows"],"latest_commit_sha":null,"homepage":"http://eridem.net/hostify","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/eridem.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":"2017-02-19T16:59:19.000Z","updated_at":"2020-06-24T01:44:38.000Z","dependencies_parsed_at":"2022-08-25T03:41:13.168Z","dependency_job_id":null,"html_url":"https://github.com/eridem/hostify","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eridem%2Fhostify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eridem%2Fhostify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eridem%2Fhostify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eridem%2Fhostify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eridem","download_url":"https://codeload.github.com/eridem/hostify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240434308,"owners_count":19800550,"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":["cli","hosts","ip","javascript","linux","macos","nodejs","windows"],"created_at":"2024-11-10T02:37:25.245Z","updated_at":"2026-04-09T20:03:15.386Z","avatar_url":"https://github.com/eridem.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status][travis-image]][travis-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n[![NPM version][npm-image]][npm-url]\n[![js-standard-style][standard-image]][standard-url]\n\n[travis-url]: https://travis-ci.org/eridem/hostify\n[travis-image]: https://img.shields.io/travis/eridem/hostify/master.svg\n[standard-url]: http://standardjs.com/\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[npm-url]: https://www.npmjs.com/package/hostify\n[npm-image]: https://img.shields.io/npm/v/hostify.svg\n[coveralls-url]: https://coveralls.io/github/eridem/hostify?branch=master\n[coveralls-image]: https://coveralls.io/repos/github/eridem/hostify/badge.svg?branch=master\n\n# Hostify\n\n![Icon](https://github.com/eridem/hostify/raw/master/doc/icon.png) \n\n*Hostify* is a module that help us to work with the `hosts` file of our operating system.\n\nIt supports both a CLI tool and a module you can use in your own project.\n\n\u003e *NOTE: library in progress. Please use with caution and report any issue on here: \u003chttps://github.com/eridem/hostify/issues\u003e*\n\n## CLI tool operations\n\n```bash\n# Usage\nhostify [COMMAND] [OPTIONS]\n\n# For help\nhostify --help\nhostify [COMMAND] --help\n```\n\n| Command | Description | Example\n|:-- |:-- |:-- |\n| `list` | Show all entries in the host file | `hostify list` |\n| `list --ipFilterExp \"REGEXP\"` | Show entries which IPs match with RegExp | `hostify list --ipFilterExp \".*\\.255\"` |\n| `list --hostFilterExp \"REGEXP\"` | Show entries which Host match with RegExp | `hostify list --hostFilterExp \".*tracking.*\"` |\n| `list --ipFilterExp \"REGEXP\" --hostFilterExp \"REGEXP\"` | Show entries which IP and Host match with both each RegExp | `hostify list --ipFilterExp \"0.0.0.0\" --hostFilterExp \".*tracking.*\"` |\n| `add --ip \"IP\" --host \"HOST\" [--comment \"COMMENT\"]` | Add a single entry to the `hosts` file | `hostify add --ip \"0.0.0.0\" --host \"tracking.localhost\" --comment \"Tracking entry\"` |\n| `delete --ipFilterExp \"REGEXP\" [--what-if]` | Delete entries which IPs match with RegExp | `hostify delete --ipFilterExp \"127.0.0.\\d+\"` |\n| `delete --hostFilterExp \"REGEXP\" [--what-if]` | Delete entries which Host match with RegExp | `hostify delete --hostFilterExp \".*project\\.local\"` |\n\n### Special options\n\n| Option | Description | Example\n|:-- |:-- |:-- |\n| `--path` | Specify path of another `hosts` file | `hostify list --path ./my-hosts.txt` |\n\n## Module interface\n\nImport module with:\n\n```javascript\nconst hostify = require('hostify').operations\n```\n\n### List\n\n```typescript\nhostify.list(options): \u003cArray\u003e{ ip: string, host: string }`\n```\n\nShow entries in the host file.\n\n| Option | Model | Default |\n|:-- |:-- |:-- |\n| `filterIpFn` | `filterIpFn: (val: string) =\u003e boolean` | `(v) =\u003e true` |\n| `filterHostFn` | `filterHostFn: (val: string) =\u003e boolean` | `(v) =\u003e true` |\n| `path` | `path: string` | OS hosts path |\n\n```javascript\nconst options = {\n  filterIpFn: (val) =\u003e val.endsWith('.255'),       // Filter IPs\n  filterHostFn: (val) =\u003e val.contains('tracking')  // Filter Hosts\n  // path: './my-hosts-file.txt'                   // Hosts file\n}\n\nconst entries = hostify.list(options)\n\nentries.forEach(entry =\u003e console.log(entry.ip, entry.host, entry.comment))\n```\n\n### Add\n\n```typescript\nhostify.add(options): \u003cArray\u003e{ ip: string, host: string }\n```\n\nAdd entries in the host file.\n\n| Option | Model | Default |\n|:-- |:-- |:-- |\n| `entries` | `\u003cArray\u003e{ ip: string, host: string, comment: string }` | `null` |\n| `path` | `path: string` | OS hosts path |\n\n```javascript\nconst options = {\n  entries: [                                       // Entries to add\n    { ip: '0.0.0.0', host: 'ad.localhost' },\n    { ip: '0.0.0.0', host: 'tracking.localhost', comment: 'Track entry' }\n  ],\n  // path: './my-hosts-file.txt'                   // Hosts file\n}\n\nconst entries = hostify.add(options)\n\nentries.forEach(entry =\u003e console.log(entry.ip, entry.host, entry.comment))\n```\n\n### Delete\n\n```typescript\nhostify.delete(options): \u003cArray\u003e{ ip: string, host: string }\n```\n\nDelete entries in the host file.\n\n| Option | Model | Default |\n|:-- |:-- |:-- |\n| `filterIpFn` | `filterIpFn: (val: string) =\u003e boolean` | `(v) =\u003e true` |\n| `filterHostFn` | `filterHostFn: (val: string) =\u003e boolean` | `(v) =\u003e true` |\n| `whatIf` | `whatIf: boolean` | `false` |\n| `path` | `path: string` | OS hosts path |\n\n```javascript\nconst options = {\n  filterIpFn: (val) =\u003e val.endsWith('.255'),       // Filter IPs\n  filterHostFn: (val) =\u003e val.contains('tracking'), // Filter Hosts\n  whatIf: true                                     // Do not execute delete operation, only obtain results\n  // path: './my-hosts-file.txt'                   // Hosts file\n}\n\nconst entries = hostify.delete(options)\n\nentries.forEach(entry =\u003e console.log(entry.ip, entry.host, entry.comment))\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feridem%2Fhostify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feridem%2Fhostify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feridem%2Fhostify/lists"}