Socket
Socket
Sign inDemoInstall

@ascari/hosts

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ascari/hosts

Edit the hosts file programmatically


Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

hosts

Edit your hosts file programmatically.

Install

npm i @ascari/hosts --save

Usage

Use set to make certain that a hostname is registered

const hosts = require('@ascari/hosts');

// Sync write to hosts file.
hosts.set('127.0.0.1', 'mywebsite.dev');
hosts.set('127.0.0.1', 'mywebsite.com');
hosts.set('127.0.0.1', 'api.mywebsite.com');

console.log('path', hosts.getPath());
console.log('entries', hosts.get());

API

method setPath(String path)

Set path of hosts file to modify.

method getPath() -> String

Get path set for hosts file.

method set(String ip, String hostname)

Add a new entry to hosts file.

method unset(String ip, RegExp|String [hostname])

Remove a existing entry or entries by their ip and hostname.

method get(String [ip], RegExp|String [pattern]) -> Array of Objects

Retrieve a entry by its id and hostname or a regexp pattern to match. If no arguments are set, then all entries are returned.

License

MIT

Keywords

FAQs

Package last updated on 24 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc