-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
208 changed files
with
28,825 additions
and
9,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,6 @@ | |
!/test/ | ||
!/tsconfig.json | ||
!/webpack.config.js | ||
!cli-cache.json | ||
tap-testdir*/ | ||
!/cli/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/.reuse/ | ||
.nyc_output/ | ||
coverage/ | ||
cli-cache.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"v8": "aa8fff11cdab94fff1a2160ee5241f5f4632e96b", | ||
"v9": "64763a341e7aa5b456e696f956759bf9b3440dc1", | ||
"v10": "a3041941586b6fb8ed7403fe3c24d81138a96005", | ||
"v11": "ab9ddc0413374fbf4879da535f82e03bc4e62cf3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const fs = require('fs/promises') | ||
|
||
/** cache npm cli version shas to NOT pull down changes we already have */ | ||
class CacheVersionSha { | ||
shouldVoid = false | ||
|
||
constructor(cache, path) { | ||
this.cache = cache | ||
this.path = path | ||
} | ||
|
||
static async load(path) { | ||
return new CacheVersionSha(JSON.parse(await fs.readFile(path, 'utf-8')), path) | ||
} | ||
|
||
get keys() { | ||
return Object.keys(this.cache) | ||
} | ||
|
||
voidOnNewKey(keys) { | ||
if (keys.length !== this.keys.length || !keys.every(key => this.keys.includes(key))) { | ||
this.shouldVoid = true | ||
} | ||
} | ||
|
||
async save() { | ||
const sortedCache = {} | ||
Object.keys(this.cache) | ||
.sort((a, b) => { | ||
const numA = parseInt(a.replace('v', ''), 10) | ||
const numB = parseInt(b.replace('v', ''), 10) | ||
return numA - numB | ||
}) | ||
.forEach(key => { | ||
sortedCache[key] = this.cache[key] | ||
}) | ||
this.cache = sortedCache | ||
await fs.writeFile(this.path, JSON.stringify(this.cache, null, 2)) | ||
return this | ||
} | ||
|
||
set(id, sha) { | ||
this.cache[id] = sha | ||
return this | ||
} | ||
|
||
same(id, value) { | ||
if (this.shouldVoid) return false | ||
return this.cache[id] === value | ||
} | ||
} | ||
|
||
module.exports = { | ||
CacheVersionSha, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.