Skip to content

Commit 1e0e690

Browse files
committedOct 12, 2022
chore: rebuild
1 parent 4e668e5 commit 1e0e690

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed
 

‎dist/index.js

+39-24
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(717);
140140
const utils_1 = __nccwpck_require__(5278);
141141
const os = __importStar(__nccwpck_require__(2037));
142142
const path = __importStar(__nccwpck_require__(1017));
143-
const uuid_1 = __nccwpck_require__(5840);
144143
const oidc_utils_1 = __nccwpck_require__(8041);
145144
/**
146145
* The code to exit an action
@@ -170,20 +169,9 @@ function exportVariable(name, val) {
170169
process.env[name] = convertedVal;
171170
const filePath = process.env['GITHUB_ENV'] || '';
172171
if (filePath) {
173-
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
174-
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
175-
if (name.includes(delimiter)) {
176-
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
177-
}
178-
if (convertedVal.includes(delimiter)) {
179-
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
180-
}
181-
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
182-
file_command_1.issueCommand('ENV', commandValue);
183-
}
184-
else {
185-
command_1.issueCommand('set-env', { name }, convertedVal);
172+
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
186173
}
174+
command_1.issueCommand('set-env', { name }, convertedVal);
187175
}
188176
exports.exportVariable = exportVariable;
189177
/**
@@ -201,7 +189,7 @@ exports.setSecret = setSecret;
201189
function addPath(inputPath) {
202190
const filePath = process.env['GITHUB_PATH'] || '';
203191
if (filePath) {
204-
file_command_1.issueCommand('PATH', inputPath);
192+
file_command_1.issueFileCommand('PATH', inputPath);
205193
}
206194
else {
207195
command_1.issueCommand('add-path', {}, inputPath);
@@ -241,7 +229,10 @@ function getMultilineInput(name, options) {
241229
const inputs = getInput(name, options)
242230
.split('\n')
243231
.filter(x => x !== '');
244-
return inputs;
232+
if (options && options.trimWhitespace === false) {
233+
return inputs;
234+
}
235+
return inputs.map(input => input.trim());
245236
}
246237
exports.getMultilineInput = getMultilineInput;
247238
/**
@@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput;
274265
*/
275266
// eslint-disable-next-line @typescript-eslint/no-explicit-any
276267
function setOutput(name, value) {
268+
const filePath = process.env['GITHUB_OUTPUT'] || '';
269+
if (filePath) {
270+
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
271+
}
277272
process.stdout.write(os.EOL);
278-
command_1.issueCommand('set-output', { name }, value);
273+
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
279274
}
280275
exports.setOutput = setOutput;
281276
/**
@@ -404,7 +399,11 @@ exports.group = group;
404399
*/
405400
// eslint-disable-next-line @typescript-eslint/no-explicit-any
406401
function saveState(name, value) {
407-
command_1.issueCommand('save-state', { name }, value);
402+
const filePath = process.env['GITHUB_STATE'] || '';
403+
if (filePath) {
404+
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
405+
}
406+
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
408407
}
409408
exports.saveState = saveState;
410409
/**
@@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
470469
return result;
471470
};
472471
Object.defineProperty(exports, "__esModule", ({ value: true }));
473-
exports.issueCommand = void 0;
472+
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
474473
// We use any as a valid input type
475474
/* eslint-disable @typescript-eslint/no-explicit-any */
476475
const fs = __importStar(__nccwpck_require__(7147));
477476
const os = __importStar(__nccwpck_require__(2037));
477+
const uuid_1 = __nccwpck_require__(5840);
478478
const utils_1 = __nccwpck_require__(5278);
479-
function issueCommand(command, message) {
479+
function issueFileCommand(command, message) {
480480
const filePath = process.env[`GITHUB_${command}`];
481481
if (!filePath) {
482482
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -488,7 +488,22 @@ function issueCommand(command, message) {
488488
encoding: 'utf8'
489489
});
490490
}
491-
exports.issueCommand = issueCommand;
491+
exports.issueFileCommand = issueFileCommand;
492+
function prepareKeyValueMessage(key, value) {
493+
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
494+
const convertedValue = utils_1.toCommandValue(value);
495+
// These should realistically never happen, but just in case someone finds a
496+
// way to exploit uuid generation let's not allow keys or values that contain
497+
// the delimiter.
498+
if (key.includes(delimiter)) {
499+
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
500+
}
501+
if (convertedValue.includes(delimiter)) {
502+
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
503+
}
504+
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
505+
}
506+
exports.prepareKeyValueMessage = prepareKeyValueMessage;
492507
//# sourceMappingURL=file-command.js.map
493508

494509
/***/ }),
@@ -1159,7 +1174,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
11591174
return result;
11601175
};
11611176
Object.defineProperty(exports, "__esModule", ({ value: true }));
1162-
exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
1177+
exports.getOctokitOptions = exports.GitHub = exports.defaults = exports.context = void 0;
11631178
const Context = __importStar(__nccwpck_require__(4087));
11641179
const Utils = __importStar(__nccwpck_require__(7914));
11651180
// octokit + plugins
@@ -1168,13 +1183,13 @@ const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044);
11681183
const plugin_paginate_rest_1 = __nccwpck_require__(4193);
11691184
exports.context = new Context.Context();
11701185
const baseUrl = Utils.getApiBaseUrl();
1171-
const defaults = {
1186+
exports.defaults = {
11721187
baseUrl,
11731188
request: {
11741189
agent: Utils.getProxyAgent(baseUrl)
11751190
}
11761191
};
1177-
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
1192+
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports.defaults);
11781193
/**
11791194
* Convience function to correctly format Octokit Options to pass into the constructor.
11801195
*

0 commit comments

Comments
 (0)
Please sign in to comment.