UNPKG

@webos-tools/cli

Version:

Command Line Interface for development webOS application and service

45 lines (39 loc) 1.11 kB
/* * Copyright (c) 2020-2024 LG Electronics Inc. * * SPDX-License-Identifier: Apache-2.0 */ (function() { const cliControl = {}; cliControl.end = function(exitCode) { let draining = 0; const streams = [process.stdout, process.stderr], exit = function() { if (!(draining--)) { process.exit(exitCode || 0); } }; streams.forEach(function(stream) { draining += 1; stream.write('', exit); }); exit(); }; if (process.stdin) { const reqExit = "@ARES-CLOSE@"; process.stdin.on("data", function(data) { let str; if (Buffer.isBuffer(data)) { str = data.toString(); } else { str = data; } if (str.trim() === reqExit) { cliControl.end(0); } }); } if (typeof module !== 'undefined' && module.exports) { module.exports = cliControl; } }());