auto-loopback-exempt
Advanced tools
Comparing version 0.1.6 to 0.1.7-0
@@ -1,21 +0,64 @@ | ||
const {spawnWinser} = require('./spawn-winser'); | ||
const isAdmin = require('is-admin'); | ||
console.info('Installing Auto Loopback Exempt Service...'); | ||
const { | ||
SERVICE_NAME, | ||
SERVICE_DISPLAY_NAME, | ||
SERVICE_DESCRIPTION, | ||
SERVICE_EXECUTABLE, | ||
SERVICE_SCRIPT, | ||
} = require('./constants'); | ||
const {nssm} = require('./nssm'); | ||
const {main} = require('./utils/main'); | ||
spawnWinser( | ||
'--install', | ||
'--autostart', | ||
'--silent', | ||
'--displayname', | ||
'Auto Loopback Exempt', | ||
'--env', | ||
`LOCALAPPDATA="${process.env.LOCALAPPDATA}"`, | ||
).then( | ||
() => { | ||
process.exit(); | ||
}, | ||
error => { | ||
console.error(error); | ||
process.exit(1); | ||
}, | ||
); | ||
main(async () => { | ||
let beingAdmin = await isAdmin(); | ||
if (!beingAdmin) { | ||
console.error('Please re-run the command with administrative privileges.'); | ||
return 1; | ||
} | ||
console.info(`Installing ${SERVICE_DISPLAY_NAME} Service...`); | ||
try { | ||
nssm('stop', SERVICE_NAME); | ||
} catch (error) { | ||
if (!/has not been started|does not exist/.test(error.message)) { | ||
throw error; | ||
} | ||
} | ||
try { | ||
nssm('remove', SERVICE_NAME, 'confirm'); | ||
} catch (error) { | ||
if (!/does not exist/.test(error.message)) { | ||
throw error; | ||
} | ||
} | ||
nssm('install', SERVICE_NAME, SERVICE_EXECUTABLE, SERVICE_SCRIPT); | ||
nssm( | ||
'set', | ||
SERVICE_NAME, | ||
`AppEnvironmentExtra`, | ||
`LOCALAPPDATA=${process.env.LOCALAPPDATA}`, | ||
); | ||
nssm('set', SERVICE_NAME, 'AppDirectory', __dirname); | ||
nssm('set', SERVICE_NAME, 'DisplayName', SERVICE_DISPLAY_NAME); | ||
nssm('set', SERVICE_NAME, 'Description', SERVICE_DESCRIPTION); | ||
console.info( | ||
'Service installed, you can make changes to the service in the prompting NSSM dialog or click "cancel" to use defaults.', | ||
); | ||
nssm('edit', SERVICE_NAME); | ||
console.info('Starting service...'); | ||
nssm('start', SERVICE_NAME); | ||
console.info('Service has been successfully started.'); | ||
return 0; | ||
}); |
{ | ||
"name": "auto-loopback-exempt", | ||
"version": "0.1.6", | ||
"displayName": "Auto Loopback Exempt", | ||
"description": "Automatically exempt loopback for all and newly added applications.", | ||
"version": "0.1.7-0", | ||
"author": "vilicvane <vilicvane@live.com>", | ||
@@ -22,6 +24,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"npm-which": "^3.0.1", | ||
"villa": "^0.3.1", | ||
"winser": "^1.0.3" | ||
"is-admin": "^2.1.1" | ||
} | ||
} |
@@ -1,13 +0,36 @@ | ||
const {spawnWinser} = require('./spawn-winser'); | ||
const isAdmin = require('is-admin'); | ||
console.info('Uninstalling Auto Loopback Exempt Service...'); | ||
const {SERVICE_NAME, SERVICE_DISPLAY_NAME} = require('./constants'); | ||
const {nssm} = require('./nssm'); | ||
const {main} = require('./utils/main'); | ||
spawnWinser('--remove', '--stop', '--silent').then( | ||
() => { | ||
process.exit(); | ||
}, | ||
error => { | ||
console.error(error); | ||
process.exit(1); | ||
}, | ||
); | ||
main(async () => { | ||
let beingAdmin = await isAdmin(); | ||
if (!beingAdmin) { | ||
console.error('Please re-run the command with administrative privileges.'); | ||
return 1; | ||
} | ||
console.info(`Removing "${SERVICE_DISPLAY_NAME}" Service...`); | ||
try { | ||
nssm('stop', SERVICE_NAME); | ||
} catch (error) { | ||
if (!/has not been started|does not exist/.test(error.message)) { | ||
throw error; | ||
} | ||
} | ||
try { | ||
nssm('remove', SERVICE_NAME, 'confirm'); | ||
} catch (error) { | ||
if (!/does not exist/.test(error.message)) { | ||
throw error; | ||
} | ||
} | ||
console.info('Service has been successfully removed.'); | ||
return 0; | ||
}); |
6208
1
7
157
+ Addedis-admin@^2.1.1
+ Addedcross-spawn@5.1.0(transitive)
+ Addedexeca@0.6.3(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedis-admin@2.1.1(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedyallist@2.1.2(transitive)
- Removednpm-which@^3.0.1
- Removedvilla@^0.3.1
- Removedwinser@^1.0.3
- Removedasync@0.9.0(transitive)
- Removedcommander@2.20.3(transitive)
- Removednpm-path@2.0.4(transitive)
- Removednpm-which@3.0.1(transitive)
- Removedstdio@0.2.2(transitive)
- Removedtslib@1.14.1(transitive)
- Removedvilla@0.3.2(transitive)
- Removedwinser@1.0.3(transitive)