UNPKG

pnpm

Version:

A fast implementation of npm install

56 lines 3.34 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 src_1 = require('../src'); const globalPath_1 = require('./support/globalPath'); const distTags_1 = require('./support/distTags'); const testDefaults_1 = require('./support/testDefaults'); const tape = require('tape'); const promisifyTape = require('tape-promise'); const exists = require('exists-file'); const path = require('path'); const prepare_1 = require('./support/prepare'); const test = promisifyTape(tape); test('cache clean removes cache', function (t) { return __awaiter(this, void 0, void 0, function* () { yield src_1.installPkgs(['is-positive'], testDefaults_1.default({ globalPath: globalPath_1.default, global: true })); const cache = path.join(globalPath_1.default, 'cache'); t.ok(yield exists(cache), 'cache is created'); yield src_1.cleanCache(globalPath_1.default); t.ok(!(yield exists(cache)), 'cache is removed'); }); }); test('should fail to update when requests are cached', function (t) { return __awaiter(this, void 0, void 0, function* () { prepare_1.default(); yield src_1.cleanCache(globalPath_1.default); const latest = 'stable'; const cacheTTL = 60 * 60; yield distTags_1.add('dep-of-pkg-with-1-dep', '1.0.0', latest); yield src_1.installPkgs(['pkg-with-1-dep'], testDefaults_1.default({ save: true, tag: latest, cacheTTL })); t.ok(yield exists('node_modules/.store/nested/dep-of-pkg-with-1-dep@1.0.0'), 'should install dep-of-pkg-with-1-dep@1.0.0'); yield distTags_1.add('dep-of-pkg-with-1-dep', '1.1.0', latest); yield src_1.install(testDefaults_1.default({ depth: 1, tag: latest, cacheTTL })); t.ok(yield exists('node_modules/.store/nested/dep-of-pkg-with-1-dep@1.0.0'), 'should not update to dep-of-pkg-with-1-dep@1.1.0'); }); }); test('should skip cahe even if it exists when cacheTTL = 0', function (t) { return __awaiter(this, void 0, void 0, function* () { prepare_1.default(); yield src_1.cleanCache(globalPath_1.default); const latest = 'stable'; yield distTags_1.add('dep-of-pkg-with-1-dep', '1.0.0', latest); yield src_1.installPkgs(['pkg-with-1-dep'], testDefaults_1.default({ save: true, tag: latest, cacheTTL: 60 * 60 })); t.ok(yield exists('node_modules/.store/nested/dep-of-pkg-with-1-dep@1.0.0'), 'should install dep-of-pkg-with-1-dep@1.0.0'); yield distTags_1.add('dep-of-pkg-with-1-dep', '1.1.0', latest); yield src_1.install(testDefaults_1.default({ depth: 1, tag: latest, cacheTTL: 0 })); t.ok(yield exists('node_modules/.store/nested/dep-of-pkg-with-1-dep@1.1.0'), 'should update to dep-of-pkg-with-1-dep@1.1.0'); }); }); //# sourceMappingURL=cache.js.map