diff --git a/lib/re-alias.js b/lib/re-alias.js index d7cbb0a..f11f241 100644 --- a/lib/re-alias.js +++ b/lib/re-alias.js @@ -36,15 +36,41 @@ exports.reAlias = async (token, host, help, exit) => { quiet: true // `quiet` }) - const targets = nowConfig && nowConfig.aliases + if (!nowConfig) { + help() + return exit(0) + } + + let pointers = [] + + if (nowConfig.alias) { + const value = nowConfig.alias + + if (typeof value === 'string') { + pointers.push(value) + } + + if (Array.isArray(value)) { + pointers = pointers.concat(nowConfig.alias) + } + + error(`Property ${chalk.grey('aliases')} is not a valid array or string`) + } + + if (nowConfig.aliases && Array.isArray(nowConfig.aliases)) { + console.log(`${chalk.red('Deprecated!')} The property ${chalk.grey('aliases')} will be ` + + `removed from the config file soon.`) + console.log('Read more about the new way here: http://bit.ly/2l2v5Fg\n') + + pointers = pointers.concat(nowConfig.aliases) + } - // the user never intended to support aliases from the package - if (!targets || !Array.isArray(targets)) { + if (pointers.length === 0) { help() return exit(0) } - for (const target of targets) { - await exports.assignAlias(target, token, host) + for (const pointer of pointers) { + await exports.assignAlias(pointer, token, host) } }