<commit_before>/**
 * @license
 * Copyright 2019 Balena Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * CLI entrypoint, but see also `bin/balena` and `bin/balena-dev` which
 * call this function.
 */
export async function run(
	cliArgs = process.argv,
	options: import('./preparser').AppOptions = {},
) {
	// The 'pkgExec' special/internal command provides a Node.js interpreter
	// for use of the standalone zip package. See pkgExec function.
	if (cliArgs.length > 3 && cliArgs[2] === 'pkgExec') {
		return pkgExec(cliArgs[3], cliArgs.slice(4));
	}

	const { globalInit } = await import('./app-common');
	const { routeCliFramework } = await import('./preparser');

	// globalInit() must be called very early on (before other imports) because
	// it sets up Sentry error reporting, global HTTP proxy settings, balena-sdk
	// shared options, and performs node version requirement checks.
	globalInit();
	await routeCliFramework(cliArgs, options);
}

/**
 * Implements the 'pkgExec' command, used as a way to provide a Node.js
 * interpreter for child_process.spawn()-like operations when the CLI is
 * executing as a standalone zip package (built-in Node interpreter) and
 * the system may not have a separate Node.js installation. A present use<commit_msg>Fix 'balena push' hanging on Windows (CTRL-C was required after the unicorn)<commit_after>/**
 * @license
 * Copyright 2019 Balena Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * CLI entrypoint, but see also `bin/balena` and `bin/balena-dev` which
 * call this function.
 */
export async function run(
	cliArgs = process.argv,
	options: import('./preparser').AppOptions = {},
) {
	// The 'pkgExec' special/internal command provides a Node.js interpreter
	// for use of the standalone zip package. See pkgExec function.
	if (cliArgs.length > 3 && cliArgs[2] === 'pkgExec') {
		return pkgExec(cliArgs[3], cliArgs.slice(4));
	}

	const { globalInit } = await import('./app-common');
	const { routeCliFramework } = await import('./preparser');

	// globalInit() must be called very early on (before other imports) because
	// it sets up Sentry error reporting, global HTTP proxy settings, balena-sdk
	// shared options, and performs node version requirement checks.
	globalInit();
	await routeCliFramework(cliArgs, options);

	// Windows fix: reading from stdin prevents the process from exiting
	process.stdin.pause();
}

/**
 * Implements the 'pkgExec' command, used as a way to provide a Node.js
 * interpreter for child_process.spawn()-like operations when the CLI is
 * executing as a standalone zip package (built-in Node interpreter) and
 * the system may not have a separate Node.js installation. A present use
{'fraction_non_alphanumeric': 0.10021493820526599, 'fraction_numerical': 0.006448146157979581, 'mean_word_length': 3.977272727272727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7501057', 'n_tokens_mistral': 1039, 'n_tokens_neox': 994, 'n_words': 449}