@azure-tools/extension
Version:
Yarn-Based extension aquisition (for Azure Open Source Projects)
29 lines • 941 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensurePackageJsonExists = void 0;
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, "{}");
}
exports.ensurePackageJsonExists = ensurePackageJsonExists;
async function exists(filename) {
try {
await access(filename);
return true;
}
catch (_a) {
return false;
}
}
//# sourceMappingURL=package-manager.js.map