grep-tests-from-pull-requests
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
const { getPullRequestNumber, getPullRequestBody } = require('../src/utils') | ||
const { findTestsToRun } = require('../src/universal') | ||
const { findTestsToRun, parsePullRequestUrl } = require('../src/universal') | ||
@@ -14,2 +14,6 @@ const args = arg({ | ||
'--commit': String, | ||
// the full pull request URL like | ||
// https://github.com/bahmutov/todomvc-tests-circleci/pull/15 | ||
// can replace the individual arguments | ||
'--pr-url': String, | ||
@@ -41,2 +45,11 @@ // aliases | ||
} | ||
if (args['--pr-url']) { | ||
const parsed = parsePullRequestUrl(args['--pr-url']) | ||
debug('parsed url %s to %o', args['--pr-url'], parsed) | ||
if (parsed) { | ||
Object.assign(options, parsed) | ||
} | ||
} | ||
const envOptions = { | ||
@@ -43,0 +56,0 @@ token: process.env.GITHUB_TOKEN || process.env.PERSONAL_GH_TOKEN, |
{ | ||
"name": "grep-tests-from-pull-requests", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Grabs the test tags to run from the pull request text", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -176,2 +176,10 @@ # grep-tests-from-pull-requests | ||
**Tip:** you can pass the full GitHub pull request URL instead of passing the individual command line arguments | ||
``` | ||
$ npx should-pr-run-cypress-tests --owner bahmutov --repo todomvc-no-tests-vercel --pull 15 | ||
# is the same as | ||
$ npx should-pr-run-cypress-tests --pr-url https://github.com/bahmutov/todomvc-tests-circleci/pull/15 | ||
``` | ||
## Debugging | ||
@@ -178,0 +186,0 @@ |
@@ -148,2 +148,19 @@ // @ts-check | ||
function parsePullRequestUrl(url) { | ||
if (!url.startsWith('https://github.com')) { | ||
throw new Error(`invalid url ${url}`) | ||
} | ||
if (!url.includes('/pull/')) { | ||
throw new Error(`invalid url without pull ${url}`) | ||
} | ||
const split = url.split('/') | ||
return { | ||
owner: split[3], | ||
repo: split[4], | ||
pull: cast(split[6]), | ||
} | ||
} | ||
module.exports = { | ||
@@ -155,2 +172,3 @@ getBaseUrlFromTextLine, | ||
findTestsToRun, | ||
parsePullRequestUrl, | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28346
666
228