@stryke/fs
Version:
A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.
34 lines (32 loc) • 987 B
JavaScript
import { resolve } from "./resolve.mjs";
import { cwd } from "@stryke/path/cwd";
import { installPackage } from "@antfu/install-pkg";
import "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 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 resolve(options?.cwd || cwd());
try {
await resolve(name, { paths: [resolvePath] });
} catch {
await install(name, options);
}
};
//#endregion
export { install, packageExists };
//# sourceMappingURL=install.mjs.map