Browse Source
Read aliases from `alias` property in `now.json`
master
Leo Lamprecht
8 years ago
No known key found for this signature in database
GPG Key ID: B08517883D5E0E10
1 changed files with
31 additions and
5 deletions
-
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) |
|
|
|
} |
|
|
|
} |
|
|
|