Skip to content

Commit

Permalink
run through prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
kwypchlo committed Jan 27, 2022
1 parent 9d57f62 commit f986500
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const core = require('@actions/core');
const github = require('@actions/github');
const core = require("@actions/core");
const github = require("@actions/github");
const {
SkynetClient,
genKeyPairFromSeed,
} = require('@skynetlabs/skynet-nodejs');
} = require("@skynetlabs/skynet-nodejs");

function outputAxiosErrorMessage(error) {
if (error.response) {
Expand All @@ -13,16 +13,16 @@ function outputAxiosErrorMessage(error) {
console.log(
`${method.toUpperCase()} ${path} failed with status ${status}: ${statusText}`
);
console.log(error.response.data || 'Response contained no data');
console.log(error.response.data || "Response contained no data");
}
}

function prepareClientOptions() {
const options = {};

if (core.getInput('skynet-jwt')) {
if (core.getInput("skynet-jwt")) {
// transform skynet-jwt into a cookie accepted format
options.customCookie = `skynet-jwt=${core.getInput('skynet-jwt')}`;
options.customCookie = `skynet-jwt=${core.getInput("skynet-jwt")}`;
}

return options;
Expand All @@ -31,16 +31,16 @@ function prepareClientOptions() {
function prepareUploadOptions() {
const options = {};

if (core.getInput('try-files')) {
if (core.getInput("try-files")) {
// transform try-files input which is space separated list
// of file paths into an array of those paths
options.tryFiles = core.getInput('try-files').split(/\s+/);
options.tryFiles = core.getInput("try-files").split(/\s+/);
}

if (core.getInput('not-found-page')) {
if (core.getInput("not-found-page")) {
// transform not-found-page input which is a single file path into
// an object with a 404 key and its value being the specified path
options.errorPages = { 404: core.getInput('not-found-page') };
options.errorPages = { 404: core.getInput("not-found-page") };
}

return options;
Expand All @@ -50,11 +50,11 @@ function prepareUploadOptions() {
try {
// upload to skynet
const skynetClient = new SkynetClient(
core.getInput('portal-url'),
core.getInput("portal-url"),
prepareClientOptions()
);
const skylink = await skynetClient.uploadDirectory(
core.getInput('upload-dir'),
core.getInput("upload-dir"),
prepareUploadOptions()
);

Expand All @@ -63,17 +63,17 @@ function prepareUploadOptions() {
subdomain: true,
});

core.setOutput('skylink', skylink);
core.setOutput("skylink", skylink);
console.log(`Skylink: ${skylink}`);

core.setOutput('skylink-url', skylinkUrl);
core.setOutput("skylink-url", skylinkUrl);
console.log(`Deployed to: ${skylinkUrl}`);

// if registry is properly configured, update the skylink in the entry
if (core.getInput('registry-seed') && core.getInput('registry-datakey')) {
if (core.getInput("registry-seed") && core.getInput("registry-datakey")) {
try {
const seed = core.getInput('registry-seed');
const dataKey = core.getInput('registry-datakey');
const seed = core.getInput("registry-seed");
const dataKey = core.getInput("registry-datakey");
const { publicKey, privateKey } = genKeyPairFromSeed(seed);

const [entryUrl, resolverSkylink] = await Promise.all([
Expand All @@ -87,10 +87,10 @@ function prepareUploadOptions() {

console.log(`Registry entry updated: ${entryUrl}`);

core.setOutput('resolver-skylink-url', resolverUrl);
core.setOutput("resolver-skylink-url", resolverUrl);
console.log(`Resolver Skylink Url: ${resolverUrl}`);

core.setOutput('resolver-skylink', resolverSkylink);
core.setOutput("resolver-skylink", resolverSkylink);
console.log(`Resolver Skylink: ${resolverSkylink}`);
} catch (error) {
outputAxiosErrorMessage(error);
Expand All @@ -101,7 +101,7 @@ function prepareUploadOptions() {

// put a skylink in a pull request comment if available
if (github.context.issue.number) {
const gitHubToken = core.getInput('github-token');
const gitHubToken = core.getInput("github-token");
const octokit = github.getOctokit(gitHubToken);

try {
Expand Down

0 comments on commit f986500

Please sign in to comment.