UNPKG

@azure-tools/extension

Version:

Yarn-Based extension aquisition (for Azure Open Source Projects)

28 lines 899 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ensurePackageJsonExists = ensurePackageJsonExists; const fs_1 = require("fs"); const path_1 = require("path"); const { writeFile, access } = fs_1.promises; /** * Ensure there is a pacakge.json in the install directory. * This is to ensure that yarn add will not look for a parent package.json and install in the parent folder instead. * @param directory Directory where the package will be installed. */ async function ensurePackageJsonExists(directory) { const filename = (0, path_1.join)(directory, "package.json"); if (await exists(filename)) { return; } await writeFile(filename, "{}"); } async function exists(filename) { try { await access(filename); return true; } catch (_a) { return false; } } //# sourceMappingURL=package-manager.js.map