@commercelayer/cli
Version:
34 lines (33 loc) • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const cli_core_1 = require("@commercelayer/cli-core");
const hook = async function (opts) {
// Windows OS not supported
if (opts.config.windows)
return;
// Check if autocomplete plugin is installed
if (opts.config.getPluginsList().filter(p => p.name === '@oclif/plugin-autocomplete').length > 0) {
// If a plugin is installed/uninstalled refresh autocomplete cache
if (['plugins:install', 'plugins:uninstall'].includes(opts.Command.id)) {
try {
const acCmd = opts.config.findCommand('autocomplete');
if (acCmd && (opts.argv[0] !== '@oclif/plugin-autocomplete')) {
const runCmd = await acCmd.load();
await runCmd.run(['--refresh-cache'], opts.config);
}
}
catch (error) {
if (error.message && !error.message.includes('is not a supported shell'))
this.error(error.message);
}
}
else if ((opts.Command.id === 'autocomplete') && !opts.argv.includes('-r') && !opts.argv.includes('--refresh-cache')) {
this.log(`${cli_core_1.clColor.msg.warning('WARNING')}`);
this.log(`-- Autocomplete feature currently works only using the extended command ${cli_core_1.clColor.cyan(this.config.bin)} (not ${cli_core_1.clColor.cyan('cl')} or ${cli_core_1.clColor.cyan('clayer')}})`);
this.log(`-- If autocomplete doesn’t work immediately execute the command ${cli_core_1.clColor.cyan('autocomplete --refresh-cache')}`);
this.log('-- It will likely be necessary to open a new terminal window for the changes to take effect');
this.log('');
}
}
};
exports.default = hook;