Skip to content

Commit aa25318

Browse files
authored
fix(ncu-ci): fix cache and stats option, and use tmpdir for cache (#849)
1 parent 11d0a04 commit aa25318

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

bin/ncu-ci.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ const args = yargs(hideBin(process.argv))
7777
})
7878
.option('stats', {
7979
default: false,
80+
type: 'boolean',
8081
describe: 'Aggregate the results'
8182
})
8283
.option('cache', {
8384
default: false,
84-
describe: 'Cache the responses from Jenkins in .ncu/cache/ under' +
85-
' the node-core-utils installation directory'
85+
type: 'boolean',
86+
describe: 'Cache the responses from Jenkins in $tmpdir/ncu/cache for testing'
8687
})
8788
.option('limit', {
8889
default: 99,
@@ -199,13 +200,14 @@ const args = yargs(hideBin(process.argv))
199200
builder: (yargs) => {
200201
yargs
201202
.option('stats', {
203+
type: 'boolean',
202204
default: false,
203205
describe: 'Aggregate the results'
204206
})
205207
.option('cache', {
208+
type: 'boolean',
206209
default: false,
207-
describe: 'Cache the responses from Jenkins in .ncu/cache/ under' +
208-
' the node-core-utils installation directory'
210+
describe: 'Cache the responses from Jenkins in $tmpdir/ncu/cache for testing'
209211
})
210212
.option('limit', {
211213
default: 15,

docs/ncu-ci.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Possible use cases:
111111
is run, it picks up cached data written on disk for jobs whose results
112112
are known.
113113

114-
Note: results are cached in `${ncu_installation_path}/.ncu/cache`, so you
114+
Note: results are cached in `$tmpdir/ncu/cache`, so you
115115
may want to clean it up from time to time.
116116

117117
```

lib/cache.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import path from 'node:path';
22
import fs from 'node:fs';
3-
import { fileURLToPath } from 'node:url';
3+
import os from 'node:os';
44

55
import { writeJson, readJson, writeFile, readFile } from './file.js';
66

77
function isAsync(fn) {
88
return fn[Symbol.toStringTag] === 'AsyncFunction';
99
}
1010

11-
const parentDir = fileURLToPath(new URL('..', import.meta.url));
12-
1311
export default class Cache {
1412
constructor(dir) {
15-
this.dir = dir || this.computeCacheDir(parentDir);
13+
this.dir = dir || this.computeCacheDir(os.tmpdir());
1614
this.originals = {};
1715
this.disabled = true;
1816
}
1917

2018
computeCacheDir(base) {
21-
return path.join(base, '.ncu', 'cache');
19+
return path.join(base, 'ncu', 'cache');
2220
}
2321

2422
disable() {

0 commit comments

Comments
 (0)