@@ -10,8 +10,7 @@ const getHead = name => data => name === "pull_request" ? data.pull_request.head
10
10
const normalise = path => path . split ( "/" ) . filter ( item => item !== "" && item !== "." ) . join ( "/" ) ;
11
11
const toBoolean = value => value . toLowerCase ( ) == "true" ;
12
12
13
-
14
- const setFromPath = octokit => owner => async repo => {
13
+ const setFromPath = owner => repo => async octokit => {
15
14
try {
16
15
const input_path = core . getInput ( "path" ) ;
17
16
if ( input_path ) return normalise ( input_path ) ;
@@ -37,10 +36,10 @@ const setFromPath = octokit => owner => async repo => {
37
36
38
37
const contentsUrlDoesMatch = file => target => {
39
38
const contents_url = decodeURIComponent ( file . contents_url ) ;
40
- const contents_path = contents_url . substring ( contents_url . indexOf ( "contents/" ) , contents_url . indexOf ( "?ref=" ) ) ;
41
- const doesMatch = minimatch ( contents_path , `contents/ ${ target } ` ) ;
42
- console . log ( contents_path , `contents/ ${ target } ` , doesMatch ) ;
43
- return doesMatch ;
39
+ const start = contents_url . indexOf ( "contents/" ) ;
40
+ const end = contents_url . indexOf ( "?ref=" ) ;
41
+ const contents_path = contents_url . substring ( start , end ) ;
42
+ return minimatch ( contents_path , `contents/ ${ target } ` ) ;
44
43
} ;
45
44
46
45
( async function ( ) {
@@ -61,10 +60,9 @@ const contentsUrlDoesMatch = file => target => {
61
60
if ( response . status !== 200 ) throw `The API request for this ${ github . context . eventName } event returned ${ response . status } , expected 200.` ;
62
61
if ( response . data . status !== "ahead" ) throw `The head commit for this ${ github . context . eventName } event is not ahead of the base commit.` ;
63
62
64
- const target = await setFromPath ( octokit ) ( owner ) ( repo ) ;
65
63
const files = response . data . files ;
64
+ const target = await setFromPath ( owner ) ( repo ) ( octokit ) ;
66
65
const file = files . find ( file => contentsUrlDoesMatch ( file ) ( target ) ) ;
67
- // decodeURIComponent(file.contents_url).indexOf(`contents/${target}`) !== -1);
68
66
69
67
core . setOutput ( "name" , file ? file . filename : target ) ;
70
68
core . setOutput ( "added" , file ? file . status === "added" : false ) ;
0 commit comments