source: trip-planner-front/node_modules/@npmcli/git/lib/revs.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 640 bytes
Line 
1const pinflight = require('promise-inflight')
2const spawn = require('./spawn.js')
3const LRU = require('lru-cache')
4
5const revsCache = new LRU({
6 max: 100,
7 maxAge: 5 * 60 * 1000
8})
9
10const linesToRevs = require('./lines-to-revs.js')
11
12module.exports = async (repo, opts = {}) => {
13 if (!opts.noGitRevCache) {
14 const cached = revsCache.get(repo)
15 if (cached) {
16 return cached
17 }
18 }
19
20 return pinflight(`ls-remote:${repo}`, () =>
21 spawn(['ls-remote', repo], opts)
22 .then(({ stdout }) => linesToRevs(stdout.trim().split('\n')))
23 .then(revs => {
24 revsCache.set(repo, revs)
25 return revs
26 })
27 )
28}
Note: See TracBrowser for help on using the repository browser.