Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dgellow committed Nov 25, 2023
1 parent 1d1dda1 commit 1dfecb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 0 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33164,17 +33164,13 @@ function uploadSpecAndConfig(specPath, configPath, token) {
return __awaiter(this, void 0, void 0, function* () {
const formData = new form_data_1.default();
// append a spec file
const specStats = fs_1.default.statSync(specPath);
formData.append('oasSpec', fs_1.default.createReadStream(specPath), {
contentType: 'text/plain',
knownLength: specStats.size,
});
// append a config file, if present
if (configPath) {
const configStats = fs_1.default.statSync(configPath);
formData.append('stainlessConfig', fs_1.default.createReadStream(configPath), {
contentType: 'text/plain',
knownLength: configStats.size,
});
}
const response = yield (0, node_fetch_1.default)('https://api.stainlessapi.com/api/spec', {
Expand Down
8 changes: 2 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import { getInput } from '@actions/core';
import { error, info } from 'console';
import { writeFile } from 'fs-extra';
import fetch from 'node-fetch';
import fetch, { Response } from 'node-fetch';
import FormData from 'form-data';

export async function main() {
Expand All @@ -28,22 +28,18 @@ export async function main() {
}
}

async function uploadSpecAndConfig(specPath: string, configPath: string, token: string) {
async function uploadSpecAndConfig(specPath: string, configPath: string, token: string): Promise<Response> {
const formData = new FormData();

// append a spec file
const specStats = fs.statSync(specPath);
formData.append('oasSpec', fs.createReadStream(specPath), {
contentType: 'text/plain',
knownLength: specStats.size,
});

// append a config file, if present
if (configPath) {
const configStats = fs.statSync(configPath);
formData.append('stainlessConfig', fs.createReadStream(configPath), {
contentType: 'text/plain',
knownLength: configStats.size,
});
}

Expand Down

0 comments on commit 1dfecb3

Please sign in to comment.