Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bin/ncu-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ const args = yargs(hideBin(process.argv))
})
.option('stats', {
default: false,
type: 'boolean',
describe: 'Aggregate the results'
})
.option('cache', {
default: false,
describe: 'Cache the responses from Jenkins in .ncu/cache/ under' +
' the node-core-utils installation directory'
type: 'boolean',
describe: 'Cache the responses from Jenkins in $tmpdir/ncu/cache for testing'
})
.option('limit', {
default: 99,
Expand Down Expand Up @@ -199,13 +200,14 @@ const args = yargs(hideBin(process.argv))
builder: (yargs) => {
yargs
.option('stats', {
type: 'boolean',
default: false,
describe: 'Aggregate the results'
})
.option('cache', {
type: 'boolean',
default: false,
describe: 'Cache the responses from Jenkins in .ncu/cache/ under' +
' the node-core-utils installation directory'
describe: 'Cache the responses from Jenkins in $tmpdir/ncu/cache for testing'
})
.option('limit', {
default: 15,
Expand Down
2 changes: 1 addition & 1 deletion docs/ncu-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Possible use cases:
is run, it picks up cached data written on disk for jobs whose results
are known.

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

```
Expand Down
8 changes: 3 additions & 5 deletions lib/cache.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import path from 'node:path';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import os from 'node:os';

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

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

const parentDir = fileURLToPath(new URL('..', import.meta.url));

export default class Cache {
constructor(dir) {
this.dir = dir || this.computeCacheDir(parentDir);
this.dir = dir || this.computeCacheDir(os.tmpdir());
this.originals = {};
this.disabled = true;
}

computeCacheDir(base) {
return path.join(base, '.ncu', 'cache');
return path.join(base, 'ncu', 'cache');
}

disable() {
Expand Down
Loading