UNPKG

flow-typed

Version:

A repository of high quality flow type definitions

47 lines (39 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.name = exports.description = void 0; exports.run = run; exports.setup = setup; var _cacheRepoUtils = require("../lib/cacheRepoUtils"); var _node = require("../lib/node"); const name = 'update-cache'; exports.name = name; const description = 'Update the flow-typed definitions cache'; exports.description = description; function setup(yargs) { return yargs.usage(`$0 ${name} - ${description}`).options({ cacheDir: { alias: 'c', describe: 'Directory (absolute or relative path, ~ is not supported) to store cache of libdefs', type: 'string', demandOption: false } }); } async function run(args) { try { if (typeof args.cacheDir === 'string') { const cacheDir = _node.path.resolve(args.cacheDir); console.log('• Setting cache dir', cacheDir); (0, _cacheRepoUtils._setCustomCacheDir)(cacheDir); } console.log('Updating flow-typed definitions...'); await (0, _cacheRepoUtils.ensureCacheRepo)(); console.log('Definitions update successful!'); return 0; } catch (e) { console.error(`Update failed: ${e.message}`); return 1; } }