{"version":3,"file":"install.mjs","names":[],"sources":["../src/install.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n                       ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website:                  https://stormsoftware.com\n Repository:               https://github.com/storm-software/stryke\n Documentation:            https://docs.stormsoftware.com/projects/stryke\n Contact:                  https://stormsoftware.com/contact\n\n SPDX-License-Identifier:  Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { InstallPackageOptions } from \"@antfu/install-pkg\";\nimport { installPackage } from \"@antfu/install-pkg\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport \"tinyexec\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Install a specific package\n *\n * @param name - The name of the package to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n  name: string,\n  options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a list of packages\n *\n * @param names - The list of package names to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n  names: string[],\n  options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a specific or list of packages\n *\n * @param nameOrNames - The name or names of packages to install\n * @param options - The options to use when installing the package\n * @returns The result of the command or an exception\n */\nexport async function install(\n  nameOrNames: string | string[],\n  options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>> {\n  return installPackage(nameOrNames, options);\n}\n\n/**\n * Check if a package exists and install it if it does not\n *\n * @param name - The name of the package to check\n * @param options - The options to use when installing the package\n */\nexport const packageExists = async (\n  name: string,\n  options?: InstallPackageOptions\n) => {\n  const resolvePath = await resolve(options?.cwd || cwd());\n  try {\n    await resolve(name, { paths: [resolvePath] });\n  } catch {\n    await install(name, options);\n  }\n};\n"],"mappings":";;;;;;;;;;;;;AAqDA,eAAsB,QACpB,aACA,SAC4C;AAC5C,QAAO,eAAe,aAAa,QAAQ;;;;;;;;AAS7C,MAAa,gBAAgB,OAC3B,MACA,YACG;CACH,MAAM,cAAc,MAAM,QAAQ,SAAS,OAAO,KAAK,CAAC;AACxD,KAAI;AACF,QAAM,QAAQ,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;SACvC;AACN,QAAM,QAAQ,MAAM,QAAQ"}