forked from 10up/wp-local-docker-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhosts.js
executable file
·43 lines (38 loc) · 1005 Bytes
/
hosts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
const hostile = require( 'hostile' );
const commandUtils = require( './src/command-utils' );
const add = function( hosts ) {
hostile.set( '127.0.0.1', hosts, function( err ) {
if (err) {
console.error(err)
} else {
console.log('Added to hosts file successfully!')
}
});
};
const remove = function( hosts ) {
hostile.remove( '127.0.0.1', hosts, function( err ) {
if (err) {
console.error(err)
} else {
console.log('Removed from hosts file successfully!')
}
});
};
const command = function() {
let mode = commandUtils.command();
let args = commandUtils.commandArgs();
switch( mode ) {
case 'add':
add( args );
break;
case 'remove':
remove( args );
break;
default:
console.error( "Invalid hosts command" );
process.exit(1);
break;
}
};
command();