-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22418fc
commit adf8315
Showing
2 changed files
with
17 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
'use strict' | ||
const fetch = require('node-fetch') | ||
const { request } = require('undici') | ||
const yaml = require('js-yaml') | ||
const GHRAW = 'https://raw.githubusercontent.com/' | ||
|
||
module.exports.getPackageJson = async function getPackageJson (project) { | ||
const resp = await fetch(`${GHRAW}${project.repoOwner}/${project.repoName}/${project.repoBranch}${project.repoDirectory}package.json`) | ||
if (resp.status !== 200) { | ||
const e = new Error(`Non-200 Response: ${resp.status}`) | ||
e.status = resp.status | ||
e.body = await resp.text() | ||
const resp = await request(`${GHRAW}${project.repoOwner}/${project.repoName}/${project.repoBranch}${project.repoDirectory}package.json`) | ||
if (resp.statusCode !== 200) { | ||
const e = new Error(`Non-200 Response: ${resp.statusCode}`) | ||
e.status = resp.statusCode | ||
e.body = await resp.body.text() | ||
throw e | ||
} | ||
return resp.json() | ||
return resp.body.json() | ||
} | ||
|
||
module.exports.getTravisConfig = async function getTravisConfig (project) { | ||
const resp = await fetch(`${GHRAW}${project.repoOwner}/${project.repoName}/${project.repoBranch}${project.repoDirectory}.travis.yml`) | ||
if (resp.status !== 200) { | ||
const e = new Error(`Non-200 Response: ${resp.status}`) | ||
e.status = resp.status | ||
e.body = await resp.text() | ||
const resp = await request(`${GHRAW}${project.repoOwner}/${project.repoName}/${project.repoBranch}${project.repoDirectory}.travis.yml`) | ||
|
||
if (resp.statusCode !== 200) { | ||
const e = new Error(`Non-200 Response: ${resp.statusCode}`) | ||
e.status = resp.statusCode | ||
e.body = await resp.body.text() | ||
throw e | ||
} | ||
const travisTxt = await resp.text() | ||
|
||
const travisTxt = await resp.body.text() | ||
|
||
return yaml.safeLoad(travisTxt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters