From f2a4ee0adc1beacf49f8303599c905543cf1bba3 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Tue, 3 Jan 2017 01:22:11 -0800 Subject: [PATCH] XO Happiness (#197) * Comply to rule 'no-useless-escape' * Comply to rule 'no-case-declarations' * Comply to rule 'ava/no-ignored-test-files' --- bin/now-alias.js | 15 ++++++++------- bin/now-deploy.js | 4 ++-- bin/now-domains.js | 12 ++++++------ bin/now-remove.js | 2 +- lib/git.js | 3 ++- lib/to-host.js | 2 +- package.json | 5 +---- 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/bin/now-alias.js b/bin/now-alias.js index d7a0207..4f29f88 100755 --- a/bin/now-alias.js +++ b/bin/now-alias.js @@ -120,8 +120,8 @@ async function run(token) { const args = argv._.slice(1) switch (subcommand) { - case 'list': case 'ls': + case 'list': { if (args.length !== 0) { error(`Invalid number of arguments. Usage: ${chalk.cyan('`now alias ls`')}`) return exit(1) @@ -160,9 +160,9 @@ async function run(token) { } break - - case 'remove': + } case 'rm': + case 'remove': { const _target = String(args[0]) if (!_target) { const err = new Error('No alias id specified') @@ -201,17 +201,17 @@ async function run(token) { } break - + } case 'add': - case 'set': + case 'set': { if (args.length !== 2) { error(`Invalid number of arguments. Usage: ${chalk.cyan('`now alias set `')}`) return exit(1) } await alias.set(String(args[0]), String(args[1])) break - - default: + } + default: { if (argv._.length === 0) { await realias(alias) break @@ -228,6 +228,7 @@ async function run(token) { help() exit(1) } + } } alias.close() diff --git a/bin/now-deploy.js b/bin/now-deploy.js index b440413..50a4431 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -235,7 +235,7 @@ async function sync(token) { Object.assign(gitRepo, gitParts) const searchMessage = setTimeout(() => { - console.log(`> Didn\'t find directory. Searching on ${gitRepo.type}...`) + console.log(`> Didn't find directory. Searching on ${gitRepo.type}...`) }, 500) try { @@ -416,7 +416,7 @@ async function sync(token) { if ((key in process.env)) { console.log(`> Reading ${chalk.bold(`"${chalk.bold(key)}"`)} from your env (as no value was specified)`) // escape value if it begins with @ - val = process.env[key].replace(/^\@/, '\\@') + val = process.env[key].replace(/^@/, '\\@') } else { error(`No value specified for env ${chalk.bold(`"${chalk.bold(key)}"`)} and it was not found in your env.`) return process.exit(1) diff --git a/bin/now-domains.js b/bin/now-domains.js index 7c18533..a1f58a3 100755 --- a/bin/now-domains.js +++ b/bin/now-domains.js @@ -141,7 +141,7 @@ async function run(token) { switch (subcommand) { case 'ls': - case 'list': + case 'list': { if (args.length !== 0) { error('Invalid number of arguments') return exit(1) @@ -174,9 +174,9 @@ async function run(token) { } break - + } case 'rm': - case 'remove': + case 'remove': { if (args.length !== 1) { error('Invalid number of arguments') return exit(1) @@ -214,9 +214,9 @@ async function run(token) { exit(1) } break - + } case 'add': - case 'set': + case 'set': { if (args.length !== 1) { error('Invalid number of arguments') return exit(1) @@ -238,7 +238,7 @@ async function run(token) { console.log('> Verification required: Please rerun this command after some time') } break - + } default: error('Please specify a valid subcommand: ls | add | rm') help() diff --git a/bin/now-remove.js b/bin/now-remove.js index 8abf396..df1886f 100755 --- a/bin/now-remove.js +++ b/bin/now-remove.js @@ -128,7 +128,7 @@ async function remove(token) { const matches = deployments.filter(d => { return ids.find(id => { // `url` should match the hostname of the deployment - let u = id.replace(/^https\:\/\//i, '') + let u = id.replace(/^https:\/\//i, '') if (u.indexOf('.') === -1) { // `.now.sh` domain is implied if just the subdomain is given diff --git a/lib/git.js b/lib/git.js index c80306e..dab9c05 100644 --- a/lib/git.js +++ b/lib/git.js @@ -73,10 +73,11 @@ const downloadRepo = async repoPath => { let url switch (pathParts.type) { - case 'GitLab': + case 'GitLab': { const ref = pathParts.ref ? `?ref=${pathParts.ref}` : '' url = `https://gitlab.com/${pathParts.main}/repository/archive.tar` + ref break + } case 'Bitbucket': url = `https://bitbucket.org/${pathParts.main}/get/${pathParts.ref || 'default'}.zip` break diff --git a/lib/to-host.js b/lib/to-host.js index 1737102..dbc3894 100644 --- a/lib/to-host.js +++ b/lib/to-host.js @@ -14,5 +14,5 @@ export default function toHost(url) { // remove any path if present // `a.b.c/` => `a.b.c` - return url.replace(/(\/\/)?([^\/]+)(.*)/, '$2') + return url.replace(/(\/\/)?([^/]+)(.*)/, '$2') } diff --git a/package.json b/package.json index 8eb45a9..9035fcd 100644 --- a/package.json +++ b/package.json @@ -51,14 +51,11 @@ ], "rules": { "import/no-unresolved": 0, - "ava/no-ignored-test-files": 0, "max-depth": 0, "no-use-before-define": 0, "complexity": 0, "unicorn/no-process-exit": 0, - "no-control-regex": 0, - "no-case-declarations": 0, - "no-useless-escape": 0 + "no-control-regex": 0 } }, "bin": {