@stryke/fs
Version:
A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.
36 lines (34 loc) • 1.23 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
const require_resolve = require('./resolve.cjs');
let _stryke_path_cwd = require("@stryke/path/cwd");
let _antfu_install_pkg = require("@antfu/install-pkg");
require("tinyexec");
//#region src/install.ts
/**
* Install a specific or list of packages
*
* @param nameOrNames - The name or names of packages to install
* @param options - The options to use when installing the package
* @returns The result of the command or an exception
*/
async function install(nameOrNames, options) {
return (0, _antfu_install_pkg.installPackage)(nameOrNames, options);
}
/**
* Check if a package exists and install it if it does not
*
* @param name - The name of the package to check
* @param options - The options to use when installing the package
*/
const packageExists = async (name, options) => {
const resolvePath = await require_resolve.resolve(options?.cwd || (0, _stryke_path_cwd.cwd)());
try {
await require_resolve.resolve(name, { paths: [resolvePath] });
} catch {
await install(name, options);
}
};
//#endregion
exports.install = install;
exports.packageExists = packageExists;