function getNpmPackageVersion(pkg, { global = false } = {}) {
		const npmBinArgs = ["bin", "-g"];
		const npmLsArgs = ["ls", "--depth=0", "--json", pkg];

		if (global) {
			npmLsArgs.push("-g");
		}

		try {
			const parsedStdout = JSON.parse(execCommand("npm", npmLsArgs));

			/*
			 * Checking globally returns an empty JSON object, while local checks
			 * include the name and version of the local project.
			 */
			if (
				Object.keys(parsedStdout).length === 0 ||
				!(parsedStdout.dependencies && parsedStdout.dependencies.eslint)
			) {
				return "Not found";
			}

			const [, processBinPath] = process.argv;
			let npmBinPath;

			try {
				npmBinPath = execCommand("npm", npmBinArgs);
			} catch (e) {
				log.error(
					`Error finding npm binary path when running command \`npm ${npmBinArgs.join(" ")}\``,
				);
				throw e;
			}

			const isGlobal = isChildOfDirectory(npmBinPath, processBinPath);
			let pkgVersion = parsedStdout.dependencies.eslint.version;

			if ((global && isGlobal) || (!global && !isGlobal)) {
				pkgVersion += " (Currently used)";
			}

			return normalizeVersionStr(pkgVersion);
		} catch (e) {
			log.error(
				`Error finding ${pkg} version running the command \`npm ${npmLsArgs.join(" ")}\``,
			);
			throw e;
		}
	}
Gets installed npm package version.
@param {string} pkg The package to check.
@param {boolean} global Whether to check globally or not.
@throws {Error} As may be collected by `cross-spawn.sync`.
@returns {string} The normalized version returned by the command.