UNPKG

pnpm

Version:

A fast implementation of npm install

32 lines 1.32 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments)).next()); }); }; const path = require('path'); const thenify = require('thenify'); const lockfile = require('lockfile'); const lock = thenify(lockfile.lock); const unlock = thenify(lockfile.unlock); function default_1(storePath, fn) { return __awaiter(this, void 0, void 0, function* () { const lockfile = path.resolve(storePath, 'lock'); yield lock(lockfile); try { const result = yield fn(); yield unlock(lockfile); return result; } catch (err) { yield unlock(lockfile); throw err; } }); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; //# sourceMappingURL=lock.js.map