npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-localhosts

v0.1.0

Published

Change your local machine hosts

Downloads

1,462

Readme

grunt-localhosts v0.1.0 NPM Version NPM

Change your local machine hosts.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-localhosts --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-localhosts');

change localhosts task

Run this task with the grunt localhosts command.

This task was designed to be used in conjunction with another task grunt server which open local server binds on localhosts 127.0.0.1, but if your page requests some cgi server for example cgi.qun.qq.com, the Same-Origin Policy will not allow you do this by localhosts. At the time you can change your local hosts file 127.0.0.1 qun.qq.com, then you can access the cgi server by CORS just simply open you local pages at "qun.qq.com/index.html", by the way, change the grunt connect open page to url "qun.qq.com" not localhost !

Options

rules

Type: Array Default: `empty array'

just statement which localhost you want to set or remove !

rules: [{
    ip: '127.0.0.1',    // point domain "A" to address "B"
    hostname: 'qun.qq.com',
    type: 'set'
}]
rules: [{
    domain: 'baidu.com',    // point domain "A" to domain "B"
    hostname: 'qun.qq.com',
    type: 'set'
}]

Usage examples

Basic Use

In this example, grunt localhosts (or more verbosely, grunt localhosts:set) will change your localhosts as you wish, obviously you can use 'grunt localhosts:remove' too.

// Project configuration.
grunt.initConfig({
    localhosts: {
        set : {
            options: {
                rules: [{
                    ip: '127.0.0.1',
                    hostname: 'qun.qq.com',
                    type: 'set'
                }, {
                    ip: '127.0.0.1',
                    hostname: 'find.qq.com',
                    type: 'set'
                }, {
                    domain: 'baidu.com',    // point domain "A" to domain "B"
                    hostname: 'find.qq.com',
                    type: 'set'
                }]
            }
        },
        remove : {
            options: {
                rules: [{
                    ip: '127.0.0.1',
                    hostname: 'qun.qq.com',
                    type: 'remove'
                }]
            }
        }
    },
});


grunt.registerTask('serve', function (target) {
    grunt.task.run([
        'concurrent:server',
        "localhosts:set",
        'connect:livereload',
        'open:server',
        'watch'
    ]);
});

grunt.registerTask('build', [
        'localhosts:remove',    // clear previously set localhosts
        '.......'    // content removed for brevity
]);

Release History

  • 2016-01-28   v0.1.0   handle writing file permission denied
  • 2016-01-27   v0.0.9   Add dns lookup support. thx @Filip Spiridonov
  • 2014-10-24   v0.0.8   Add multiple rules support. thx @NameFILIP
  • 2012-04-10   v0.0.7   Add manufacturer info.
  • 2012-04-09   v0.0.5   Bug fix.
  • 2012-04-08   v0.0.3   Officially released.
  • 2012-04-08   v0.0.2   Work in progress, not yet officially released, just add some necessary node_modules !
  • 2012-04-04   v0.0.1   Work in progress, not yet officially released.

About

grunt-localhosts is an open-source project by Tencent which builds on top of Node.js.

Used by people within (JOIN US)

Tencent Xiaomi


Task submitted by materliu

This file was generated on Fri Apr 4 2014 22:38:50.