Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ var argv = minimist(process.argv.slice(2))

var command = argv._[0]

if (argv['file'])
{
var file = argv['file']
console.log(chalk.yellow('Opening file: ' + file))
hostile.setFile(file);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks for existence of param independent of command.

if (command === 'list' || command === 'ls') list()
if (command === 'set') set(argv._[1], argv._[2])
if (command === 'remove') remove(argv._[1])
Expand All @@ -30,6 +37,8 @@ function help () {
remove [domain] Remove a domain from the hosts file
load [file] Load a set of host entries from a file
unload [file] Remove a set of host entries from a file

optional --file parameter to all commands to allow for manipulating other hosts files in non standard locations
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding to the help prompt.


*/ }.toString().split(/\n/).slice(1, -1).join('\n'))
}
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ exports.HOSTS = WINDOWS
* @param {function(err, lines)=} cb
*/

exports.setFile = function(filePath)
{
exports.HOSTS = filePath
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the app runs per instance this should be reset every time it's run unless I'm missing something.

exports.getFile = function (filePath, preserveFormatting, cb) {
var lines = []
if (typeof cb !== 'function') {
Expand Down