Skip to content

Commit b57d538

Browse files
committed
Cache Collector scan dir right after run command
Rather than cache after all run commands, it should be cached immediately after the run command that procuces the scan dir so that if additional runs change the output of previous runs the modified output isn't cached. Closes gh-40
1 parent 6757c71 commit b57d538

2 files changed

+8
-6
lines changed

lib/inject-collector-cache-config-extension.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,17 @@ module.exports.register = function ({ playbook, config = {} }) {
6969
}
7070
logger.info(`Use the cache found at ${cacheDir}`)
7171
} else {
72+
const cachedConfig = []
7273
const normalizedCollectorConfig = Array.isArray(collectorConfig) ? collectorConfig : [collectorConfig]
73-
origin.descriptor.ext.collector = normalizedCollectorConfig
74+
origin.descriptor.ext.collector = cachedConfig
7475
normalizedCollectorConfig.forEach((collector) => {
7576
const { scan: scanConfig = [] } = collector
7677
// cache the output of the build
7778
const scanDir = expandPath(scanConfig.dir, expandPathContext)
7879
logger.info(`Configuring collector to cache '${scanDir}' at '${cacheDir}'`)
7980
const cachedCollectorConfig = createCachedCollectorConfig(scanDir, cacheDir)
80-
normalizedCollectorConfig.push.apply(normalizedCollectorConfig, cachedCollectorConfig)
81+
cachedConfig.push(collector)
82+
cachedConfig.push.apply(cachedConfig, cachedCollectorConfig)
8183
})
8284
// add the zip of cache to be published
8385
zipInfo.push({ cacheDir, zipCacheFile })

test/inject-collector-cache-config-extension-test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ describe('inject-collector-cache-config-extension', () => {
229229
},
230230
},
231231
{
232-
scan: {
233-
dir: './build/antora-resources-2',
232+
run: {
233+
command: `node '${resolvedCacheScanDirIndexJs}' '${scan}' '${cache}'`,
234234
},
235235
},
236236
{
237-
run: {
238-
command: `node '${resolvedCacheScanDirIndexJs}' '${scan}' '${cache}'`,
237+
scan: {
238+
dir: './build/antora-resources-2',
239239
},
240240
},
241241
{

0 commit comments

Comments
 (0)