From e0e8b183bd75e87fa4c09710fe3399007fcdc3e6 Mon Sep 17 00:00:00 2001 From: kitsuned <80879390+kitsuned@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:14:37 +0300 Subject: [PATCH] elevate-service: allow to be imported from third-party modules without side effects --- services/elevate-service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/elevate-service.ts b/services/elevate-service.ts index 9bbfff6..f10737a 100755 --- a/services/elevate-service.ts +++ b/services/elevate-service.ts @@ -113,7 +113,7 @@ function patchRolesFile(path: string, requiredNames: string[] = ['*', 'com.webos return false; } -function main(argv: string[]) { +export default function main(argv: string[]) { let [serviceName = 'org.webosbrew.hbchannel.service', appName = serviceName.split('.').slice(0, -1).join('.')] = argv; if (serviceName === 'org.webosbrew.hbchannel') { @@ -232,4 +232,6 @@ function main(argv: string[]) { } } -main(process.argv.slice(2)); +if (require.main === module) { + main(process.argv.slice(2)); +}