Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Manipulate the /etc/hosts file
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
LICENSE
README.md
package.json
testReplace.js

README.md

node-hostsfile

Manipulate the /etc/hosts file.

var hf = require('./lib/hostsfile');

hf.readHostsFile(function (err, data) {
    if (err)
        throw err;

    var hosts = [
        {ip: '10.1.2.3', names: ['test1', 'test1-alias']},
    ];

    data = hf.addHosts(data, hosts, 'test');
    hf.replaceHostsFile(data, function (err) {
        if (err)
            throw err;
        console.log('Done');
    });
});

License

MIT

Something went wrong with that request. Please try again.