Skip to content

Commit accf675

Browse files
authored
Update @actions/core (actions#142)
1 parent 614aa4a commit accf675

File tree

3 files changed

+108
-16
lines changed

3 files changed

+108
-16
lines changed

dist/index.js

Lines changed: 104 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,32 @@ class SemVer {
12431243
module.exports = SemVer
12441244

12451245

1246+
/***/ }),
1247+
1248+
/***/ 82:
1249+
/***/ (function(__unusedmodule, exports) {
1250+
1251+
"use strict";
1252+
1253+
// We use any as a valid input type
1254+
/* eslint-disable @typescript-eslint/no-explicit-any */
1255+
Object.defineProperty(exports, "__esModule", { value: true });
1256+
/**
1257+
* Sanitizes an input into a string so it can be passed into issueCommand safely
1258+
* @param input input to sanitize into a string
1259+
*/
1260+
function toCommandValue(input) {
1261+
if (input === null || input === undefined) {
1262+
return '';
1263+
}
1264+
else if (typeof input === 'string' || input instanceof String) {
1265+
return input;
1266+
}
1267+
return JSON.stringify(input);
1268+
}
1269+
exports.toCommandValue = toCommandValue;
1270+
//# sourceMappingURL=utils.js.map
1271+
12461272
/***/ }),
12471273

12481274
/***/ 87:
@@ -1252,6 +1278,42 @@ module.exports = require("os");
12521278

12531279
/***/ }),
12541280

1281+
/***/ 102:
1282+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
1283+
1284+
"use strict";
1285+
1286+
// For internal use, subject to change.
1287+
var __importStar = (this && this.__importStar) || function (mod) {
1288+
if (mod && mod.__esModule) return mod;
1289+
var result = {};
1290+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1291+
result["default"] = mod;
1292+
return result;
1293+
};
1294+
Object.defineProperty(exports, "__esModule", { value: true });
1295+
// We use any as a valid input type
1296+
/* eslint-disable @typescript-eslint/no-explicit-any */
1297+
const fs = __importStar(__webpack_require__(747));
1298+
const os = __importStar(__webpack_require__(87));
1299+
const utils_1 = __webpack_require__(82);
1300+
function issueCommand(command, message) {
1301+
const filePath = process.env[`GITHUB_${command}`];
1302+
if (!filePath) {
1303+
throw new Error(`Unable to find environment variable for file command ${command}`);
1304+
}
1305+
if (!fs.existsSync(filePath)) {
1306+
throw new Error(`Missing file at path: ${filePath}`);
1307+
}
1308+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
1309+
encoding: 'utf8'
1310+
});
1311+
}
1312+
exports.issueCommand = issueCommand;
1313+
//# sourceMappingURL=file-command.js.map
1314+
1315+
/***/ }),
1316+
12551317
/***/ 120:
12561318
/***/ (function(module, __unusedexports, __webpack_require__) {
12571319

@@ -2422,6 +2484,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24222484
};
24232485
Object.defineProperty(exports, "__esModule", { value: true });
24242486
const os = __importStar(__webpack_require__(87));
2487+
const utils_1 = __webpack_require__(82);
24252488
/**
24262489
* Commands
24272490
*
@@ -2476,13 +2539,13 @@ class Command {
24762539
}
24772540
}
24782541
function escapeData(s) {
2479-
return (s || '')
2542+
return utils_1.toCommandValue(s)
24802543
.replace(/%/g, '%25')
24812544
.replace(/\r/g, '%0D')
24822545
.replace(/\n/g, '%0A');
24832546
}
24842547
function escapeProperty(s) {
2485-
return (s || '')
2548+
return utils_1.toCommandValue(s)
24862549
.replace(/%/g, '%25')
24872550
.replace(/\r/g, '%0D')
24882551
.replace(/\n/g, '%0A')
@@ -2603,6 +2666,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
26032666
};
26042667
Object.defineProperty(exports, "__esModule", { value: true });
26052668
const command_1 = __webpack_require__(431);
2669+
const file_command_1 = __webpack_require__(102);
2670+
const utils_1 = __webpack_require__(82);
26062671
const os = __importStar(__webpack_require__(87));
26072672
const path = __importStar(__webpack_require__(622));
26082673
/**
@@ -2625,11 +2690,21 @@ var ExitCode;
26252690
/**
26262691
* Sets env variable for this action and future actions in the job
26272692
* @param name the name of the variable to set
2628-
* @param val the value of the variable
2693+
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
26292694
*/
2695+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26302696
function exportVariable(name, val) {
2631-
process.env[name] = val;
2632-
command_1.issueCommand('set-env', { name }, val);
2697+
const convertedVal = utils_1.toCommandValue(val);
2698+
process.env[name] = convertedVal;
2699+
const filePath = process.env['GITHUB_ENV'] || '';
2700+
if (filePath) {
2701+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
2702+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
2703+
file_command_1.issueCommand('ENV', commandValue);
2704+
}
2705+
else {
2706+
command_1.issueCommand('set-env', { name }, convertedVal);
2707+
}
26332708
}
26342709
exports.exportVariable = exportVariable;
26352710
/**
@@ -2645,7 +2720,13 @@ exports.setSecret = setSecret;
26452720
* @param inputPath
26462721
*/
26472722
function addPath(inputPath) {
2648-
command_1.issueCommand('add-path', {}, inputPath);
2723+
const filePath = process.env['GITHUB_PATH'] || '';
2724+
if (filePath) {
2725+
file_command_1.issueCommand('PATH', inputPath);
2726+
}
2727+
else {
2728+
command_1.issueCommand('add-path', {}, inputPath);
2729+
}
26492730
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
26502731
}
26512732
exports.addPath = addPath;
@@ -2668,12 +2749,22 @@ exports.getInput = getInput;
26682749
* Sets the value of an output.
26692750
*
26702751
* @param name name of the output to set
2671-
* @param value value to store
2752+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
26722753
*/
2754+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26732755
function setOutput(name, value) {
26742756
command_1.issueCommand('set-output', { name }, value);
26752757
}
26762758
exports.setOutput = setOutput;
2759+
/**
2760+
* Enables or disables the echoing of commands into stdout for the rest of the step.
2761+
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
2762+
*
2763+
*/
2764+
function setCommandEcho(enabled) {
2765+
command_1.issue('echo', enabled ? 'on' : 'off');
2766+
}
2767+
exports.setCommandEcho = setCommandEcho;
26772768
//-----------------------------------------------------------------------
26782769
// Results
26792770
//-----------------------------------------------------------------------
@@ -2707,18 +2798,18 @@ function debug(message) {
27072798
exports.debug = debug;
27082799
/**
27092800
* Adds an error issue
2710-
* @param message error issue message
2801+
* @param message error issue message. Errors will be converted to string via toString()
27112802
*/
27122803
function error(message) {
2713-
command_1.issue('error', message);
2804+
command_1.issue('error', message instanceof Error ? message.toString() : message);
27142805
}
27152806
exports.error = error;
27162807
/**
27172808
* Adds an warning issue
2718-
* @param message warning issue message
2809+
* @param message warning issue message. Errors will be converted to string via toString()
27192810
*/
27202811
function warning(message) {
2721-
command_1.issue('warning', message);
2812+
command_1.issue('warning', message instanceof Error ? message.toString() : message);
27222813
}
27232814
exports.warning = warning;
27242815
/**
@@ -2776,8 +2867,9 @@ exports.group = group;
27762867
* Saves state for current action, the state can only be retrieved by this action's post job execution.
27772868
*
27782869
* @param name name of the state to store
2779-
* @param value value to store
2870+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
27802871
*/
2872+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27812873
function saveState(name, value) {
27822874
command_1.issueCommand('save-state', { name }, value);
27832875
}

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"author": "GitHub",
2424
"license": "MIT",
2525
"dependencies": {
26-
"@actions/core": "^1.2.3",
26+
"@actions/core": "^1.2.6",
2727
"semver": "^7.1.3"
2828
},
2929
"devDependencies": {

0 commit comments

Comments
 (0)