Skip to content

Commit 04b231e

Browse files
author
Robert Jackson
committed
Use a shared cache instance across the process.
Avoids having to duplicate the cache key in multiple places.
1 parent f0c5074 commit 04b231e

4 files changed

Lines changed: 10 additions & 14 deletions

File tree

lib/cache.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Cache = require("sync-disk-cache");
2+
const getRepoInfo = require("git-repo-info");
3+
4+
const gitInfo = getRepoInfo();
5+
const cache = new Cache(`native-class-codemod-${gitInfo.sha}`);
6+
7+
module.exports = cache;

lib/gather-telemetry.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
const puppeteer = require("puppeteer");
2-
const getRepoInfo = require("git-repo-info");
3-
const Cache = require("sync-disk-cache");
4-
5-
const gitInfo = getRepoInfo();
6-
const cache = new Cache(`native-class-codemod-${gitInfo.sha}`);
2+
const cache = require("./cache");
73

84
module.exports = async function gatherTelemetry(url) {
95
const browser = await puppeteer.launch();

transforms/ember-object/test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
const { runTransformTest } = require("codemod-cli");
44

55
// bootstrap the mock telemetry data
6-
const getRepoInfo = require("git-repo-info");
7-
const Cache = require("sync-disk-cache");
86
const walkSync = require("walk-sync");
97
const mockTelemetryData = require("./__testfixtures__/-mock-telemetry.json");
108

11-
const gitInfo = getRepoInfo();
12-
const cache = new Cache(`native-class-codemod-${gitInfo.sha}`);
9+
const cache = require("../../lib/cache");
1310

1411
// This is nasty, cwd is screwed up here for some reason
1512
let testFiles = walkSync("./transforms/ember-object/__testfixtures__", {

transforms/helpers/util/get-telemetry-for.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
const fs = require("fs-extra");
22
const path = require("path");
33
const walkSync = require("walk-sync");
4-
const getRepoInfo = require("git-repo-info");
5-
const Cache = require("sync-disk-cache");
6-
7-
const gitInfo = getRepoInfo();
8-
const cache = new Cache(`native-class-codemod-${gitInfo.sha}`);
4+
const cache = require("../../../lib/cache");
95

106
const telemetry = cache.has("telemetry")
117
? JSON.parse(cache.get("telemetry").value)

0 commit comments

Comments
 (0)