Skip to content

Commit e2e85c2

Browse files
committed
Deploy Production Code for Commit a6489cd 🚀
1 parent a6489cd commit e2e85c2

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

lib/constants.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ export interface ActionInterface {
1616
saveLocation?: string;
1717
/** The save name of the exported file. */
1818
saveName?: string;
19-
/** Determines if the output shoudl be saved or not. */
19+
/** Determines if the output should be saved or not. */
2020
setOutput: boolean;
2121
/** The format of the file being saved. */
2222
format?: string;
2323
/** Optional configuration that allows the fetch request to make a series of retry requests before failing. */
2424
retry?: boolean | null;
25+
/** The variable name the data exports as. */
26+
variableName?: string;
2527
}
2628
export interface DataInterface {
2729
/** Allows you to log the retrieved data to the terminal. */
@@ -50,6 +52,8 @@ export interface ExportInterface {
5052
setOutput: boolean;
5153
/** The format of the file to save. */
5254
format?: string;
55+
/** The variable name the data exports as. */
56+
variableName?: string;
5357
}
5458
export declare const action: {
5559
debug: boolean;
@@ -63,6 +67,7 @@ export declare const action: {
6367
saveName: string;
6468
setOutput: boolean;
6569
format: string;
70+
variableName: string;
6671
};
6772
/** Status codes for the action. */
6873
export declare enum Status {

lib/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ exports.action = {
2121
setOutput: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('set-output'))
2222
? (0, core_1.getInput)('set-output').toLowerCase() === 'true'
2323
: false,
24-
format: (0, core_1.getInput)('format')
24+
format: (0, core_1.getInput)('format'),
25+
variableName: (0, core_1.getInput)('variable-name')
2526
};
2627
/** Status codes for the action. */
2728
var Status;

lib/fetch.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import 'cross-fetch/polyfill';
22
import { DataInterface, ExportInterface, Status } from './constants';
33
export declare function retrieveData({ debug: requestDebug, endpoint, configuration, auth, isTokenRequest, retry }: DataInterface): Promise<string>;
4-
export declare function generateExport({ data, encoding, format, saveLocation, saveName, setOutput }: ExportInterface): Promise<Status>;
4+
export declare function generateExport({ data, encoding, format, saveLocation, saveName, setOutput, variableName }: ExportInterface): Promise<Status>;

lib/fetch.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,22 @@ function retrieveData({ debug: requestDebug, endpoint, configuration, auth, isTo
6262
}
6363
exports.retrieveData = retrieveData;
6464
/* Saves the data to the local file system and exports an environment variable containing the retrieved data. */
65-
function generateExport({ data, encoding, format, saveLocation, saveName, setOutput }) {
65+
function generateExport({ data, encoding, format, saveLocation, saveName, setOutput, variableName }) {
6666
return __awaiter(this, void 0, void 0, function* () {
6767
(0, core_1.info)('Saving the data... 📁');
6868
const file = `${saveLocation ? saveLocation : 'fetch-api-data-action'}/${saveName ? saveName : 'data'}.${format ? format : 'json'}`;
6969
const dataEncoding = encoding ? encoding : 'utf8';
70+
const defaultVariableName = 'fetchApiData';
71+
const environmentVariableName = variableName
72+
? variableName
73+
: defaultVariableName;
7074
try {
7175
yield (0, io_1.mkdirP)(`${saveLocation ? saveLocation : 'fetch-api-data-action'}`);
7276
yield fs_1.promises.writeFile(file, data, dataEncoding);
7377
(0, core_1.info)(`Saved ${file} 💾`);
7478
if (setOutput) {
75-
(0, core_1.exportVariable)('fetchApiData', data);
76-
(0, core_1.setOutput)('fetchApiData', data);
79+
(0, core_1.exportVariable)(environmentVariableName, data);
80+
(0, core_1.setOutput)(defaultVariableName, data);
7781
}
7882
return constants_1.Status.SUCCESS;
7983
}

0 commit comments

Comments
 (0)