File tree Expand file tree Collapse file tree 2 files changed +31
-28
lines changed
Expand file tree Collapse file tree 2 files changed +31
-28
lines changed Original file line number Diff line number Diff line change 1- const yaml = require ( 'js-yaml ' )
1+ const loadYaml = require ( './lib/loadYaml ' )
22const mergeArrayByName = require ( './lib/mergeArrayByName' )
33
44module . exports = ( robot , _ , Settings = require ( './lib/settings' ) ) => {
5- async function loadYaml ( github , params ) {
6- try {
7- const response = await github . repos . getContents ( params )
8-
9- // Ignore in case path is a folder
10- // - https://developer.github.com/v3/repos/contents/#response-if-content-is-a-directory
11- if ( Array . isArray ( response . data ) ) {
12- return null
13- }
14-
15- // we don't handle symlinks or submodule
16- // - https://developer.github.com/v3/repos/contents/#response-if-content-is-a-symlink
17- // - https://developer.github.com/v3/repos/contents/#response-if-content-is-a-submodule
18- if ( typeof response . data . content !== 'string' ) {
19- return
20- }
21-
22- return yaml . safeLoad ( Buffer . from ( response . data . content , 'base64' ) . toString ( ) ) || { }
23- } catch ( e ) {
24- if ( e . status === 404 ) {
25- return null
26- }
27-
28- throw e
29- }
30- }
31-
325 async function triggerRepositoryUpdate ( context , { owner, repo } ) {
336 const { github } = context
347
Original file line number Diff line number Diff line change 1+ const yaml = require ( 'js-yaml' )
2+
3+ async function loadYaml ( github , params ) {
4+ try {
5+ const response = await github . repos . getContents ( params )
6+
7+ // Ignore in case path is a folder
8+ // - https://developer.github.com/v3/repos/contents/#response-if-content-is-a-directory
9+ if ( Array . isArray ( response . data ) ) {
10+ return null
11+ }
12+
13+ // we don't handle symlinks or submodule
14+ // - https://developer.github.com/v3/repos/contents/#response-if-content-is-a-symlink
15+ // - https://developer.github.com/v3/repos/contents/#response-if-content-is-a-submodule
16+ if ( typeof response . data . content !== 'string' ) {
17+ return
18+ }
19+
20+ return yaml . safeLoad ( Buffer . from ( response . data . content , 'base64' ) . toString ( ) ) || { }
21+ } catch ( e ) {
22+ if ( e . status === 404 ) {
23+ return null
24+ }
25+
26+ throw e
27+ }
28+ }
29+
30+ module . exports = loadYaml
You can’t perform that action at this time.
0 commit comments