1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.name = exports.description = void 0;
|
7 | exports.run = run;
|
8 | exports.setup = setup;
|
9 |
|
10 | var _cacheRepoUtils = require("../lib/cacheRepoUtils");
|
11 |
|
12 | var _node = require("../lib/node");
|
13 |
|
14 | const name = 'update-cache';
|
15 | exports.name = name;
|
16 | const description = 'Update the flow-typed definitions cache';
|
17 | exports.description = description;
|
18 |
|
19 | function setup(yargs) {
|
20 | return yargs.usage(`$0 ${name} - ${description}`).options({
|
21 | cacheDir: {
|
22 | alias: 'c',
|
23 | describe: 'Directory (absolute or relative path, ~ is not supported) to store cache of libdefs',
|
24 | type: 'string',
|
25 | demandOption: false
|
26 | }
|
27 | });
|
28 | }
|
29 |
|
30 | async function run(args) {
|
31 | try {
|
32 | if (typeof args.cacheDir === 'string') {
|
33 | const cacheDir = _node.path.resolve(args.cacheDir);
|
34 |
|
35 | console.log('• Setting cache dir', cacheDir);
|
36 | (0, _cacheRepoUtils._setCustomCacheDir)(cacheDir);
|
37 | }
|
38 |
|
39 | console.log('Updating flow-typed definitions...');
|
40 | await (0, _cacheRepoUtils.ensureCacheRepo)();
|
41 | console.log('Definitions update successful!');
|
42 | return 0;
|
43 | } catch (e) {
|
44 | console.error(`Update failed: ${e.message}`);
|
45 | return 1;
|
46 | }
|
47 | } |
\ | No newline at end of file |