Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Commit 5f29a1c

Browse files
authored
Merge pull request #85 from thboop/updateActionsCore
Update @actions/core to the latest version
2 parents 7bf6939 + 2cf4531 commit 5f29a1c

File tree

4 files changed

+131
-37
lines changed

4 files changed

+131
-37
lines changed

.licenses/npm/@actions/core.dep.yml

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

__tests__/find-ruby.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ describe('find-ruby', () => {
1111
let tcSpy: jest.SpyInstance;
1212
let cnSpy: jest.SpyInstance;
1313

14-
beforeAll(async () => {});
14+
beforeAll(async () => {
15+
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
16+
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
17+
});
1518

1619
beforeEach(() => {
1720
tcSpy = jest.spyOn(tc, 'find');
@@ -29,7 +32,9 @@ describe('find-ruby', () => {
2932
jest.clearAllMocks();
3033
});
3134

32-
afterAll(async () => {}, 100000);
35+
afterAll(async () => {
36+
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
37+
}, 100000);
3338

3439
it('finds a version of ruby already in the cache', async () => {
3540
let toolPath = path.normalize('/cache/ruby/2.7.0/x64');

dist/index.js

Lines changed: 111 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -941,13 +941,75 @@ module.exports = require("tls");
941941

942942
/***/ }),
943943

944+
/***/ 82:
945+
/***/ (function(__unusedmodule, exports) {
946+
947+
"use strict";
948+
949+
// We use any as a valid input type
950+
/* eslint-disable @typescript-eslint/no-explicit-any */
951+
Object.defineProperty(exports, "__esModule", { value: true });
952+
/**
953+
* Sanitizes an input into a string so it can be passed into issueCommand safely
954+
* @param input input to sanitize into a string
955+
*/
956+
function toCommandValue(input) {
957+
if (input === null || input === undefined) {
958+
return '';
959+
}
960+
else if (typeof input === 'string' || input instanceof String) {
961+
return input;
962+
}
963+
return JSON.stringify(input);
964+
}
965+
exports.toCommandValue = toCommandValue;
966+
//# sourceMappingURL=utils.js.map
967+
968+
/***/ }),
969+
944970
/***/ 87:
945971
/***/ (function(module) {
946972

947973
module.exports = require("os");
948974

949975
/***/ }),
950976

977+
/***/ 102:
978+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
979+
980+
"use strict";
981+
982+
// For internal use, subject to change.
983+
var __importStar = (this && this.__importStar) || function (mod) {
984+
if (mod && mod.__esModule) return mod;
985+
var result = {};
986+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
987+
result["default"] = mod;
988+
return result;
989+
};
990+
Object.defineProperty(exports, "__esModule", { value: true });
991+
// We use any as a valid input type
992+
/* eslint-disable @typescript-eslint/no-explicit-any */
993+
const fs = __importStar(__webpack_require__(747));
994+
const os = __importStar(__webpack_require__(87));
995+
const utils_1 = __webpack_require__(82);
996+
function issueCommand(command, message) {
997+
const filePath = process.env[`GITHUB_${command}`];
998+
if (!filePath) {
999+
throw new Error(`Unable to find environment variable for file command ${command}`);
1000+
}
1001+
if (!fs.existsSync(filePath)) {
1002+
throw new Error(`Missing file at path: ${filePath}`);
1003+
}
1004+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
1005+
encoding: 'utf8'
1006+
});
1007+
}
1008+
exports.issueCommand = issueCommand;
1009+
//# sourceMappingURL=file-command.js.map
1010+
1011+
/***/ }),
1012+
9511013
/***/ 129:
9521014
/***/ (function(module) {
9531015

@@ -2986,6 +3048,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
29863048
};
29873049
Object.defineProperty(exports, "__esModule", { value: true });
29883050
const os = __importStar(__webpack_require__(87));
3051+
const utils_1 = __webpack_require__(82);
29893052
/**
29903053
* Commands
29913054
*
@@ -3040,13 +3103,13 @@ class Command {
30403103
}
30413104
}
30423105
function escapeData(s) {
3043-
return (s || '')
3106+
return utils_1.toCommandValue(s)
30443107
.replace(/%/g, '%25')
30453108
.replace(/\r/g, '%0D')
30463109
.replace(/\n/g, '%0A');
30473110
}
30483111
function escapeProperty(s) {
3049-
return (s || '')
3112+
return utils_1.toCommandValue(s)
30503113
.replace(/%/g, '%25')
30513114
.replace(/\r/g, '%0D')
30523115
.replace(/\n/g, '%0A')
@@ -3080,6 +3143,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
30803143
};
30813144
Object.defineProperty(exports, "__esModule", { value: true });
30823145
const command_1 = __webpack_require__(431);
3146+
const file_command_1 = __webpack_require__(102);
3147+
const utils_1 = __webpack_require__(82);
30833148
const os = __importStar(__webpack_require__(87));
30843149
const path = __importStar(__webpack_require__(622));
30853150
/**
@@ -3102,11 +3167,21 @@ var ExitCode;
31023167
/**
31033168
* Sets env variable for this action and future actions in the job
31043169
* @param name the name of the variable to set
3105-
* @param val the value of the variable
3170+
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
31063171
*/
3172+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31073173
function exportVariable(name, val) {
3108-
process.env[name] = val;
3109-
command_1.issueCommand('set-env', { name }, val);
3174+
const convertedVal = utils_1.toCommandValue(val);
3175+
process.env[name] = convertedVal;
3176+
const filePath = process.env['GITHUB_ENV'] || '';
3177+
if (filePath) {
3178+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
3179+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
3180+
file_command_1.issueCommand('ENV', commandValue);
3181+
}
3182+
else {
3183+
command_1.issueCommand('set-env', { name }, convertedVal);
3184+
}
31103185
}
31113186
exports.exportVariable = exportVariable;
31123187
/**
@@ -3122,7 +3197,13 @@ exports.setSecret = setSecret;
31223197
* @param inputPath
31233198
*/
31243199
function addPath(inputPath) {
3125-
command_1.issueCommand('add-path', {}, inputPath);
3200+
const filePath = process.env['GITHUB_PATH'] || '';
3201+
if (filePath) {
3202+
file_command_1.issueCommand('PATH', inputPath);
3203+
}
3204+
else {
3205+
command_1.issueCommand('add-path', {}, inputPath);
3206+
}
31263207
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
31273208
}
31283209
exports.addPath = addPath;
@@ -3145,12 +3226,22 @@ exports.getInput = getInput;
31453226
* Sets the value of an output.
31463227
*
31473228
* @param name name of the output to set
3148-
* @param value value to store
3229+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
31493230
*/
3231+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31503232
function setOutput(name, value) {
31513233
command_1.issueCommand('set-output', { name }, value);
31523234
}
31533235
exports.setOutput = setOutput;
3236+
/**
3237+
* Enables or disables the echoing of commands into stdout for the rest of the step.
3238+
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
3239+
*
3240+
*/
3241+
function setCommandEcho(enabled) {
3242+
command_1.issue('echo', enabled ? 'on' : 'off');
3243+
}
3244+
exports.setCommandEcho = setCommandEcho;
31543245
//-----------------------------------------------------------------------
31553246
// Results
31563247
//-----------------------------------------------------------------------
@@ -3167,6 +3258,13 @@ exports.setFailed = setFailed;
31673258
//-----------------------------------------------------------------------
31683259
// Logging Commands
31693260
//-----------------------------------------------------------------------
3261+
/**
3262+
* Gets whether Actions Step Debug is on or not
3263+
*/
3264+
function isDebug() {
3265+
return process.env['RUNNER_DEBUG'] === '1';
3266+
}
3267+
exports.isDebug = isDebug;
31703268
/**
31713269
* Writes debug message to user log
31723270
* @param message debug message
@@ -3177,18 +3275,18 @@ function debug(message) {
31773275
exports.debug = debug;
31783276
/**
31793277
* Adds an error issue
3180-
* @param message error issue message
3278+
* @param message error issue message. Errors will be converted to string via toString()
31813279
*/
31823280
function error(message) {
3183-
command_1.issue('error', message);
3281+
command_1.issue('error', message instanceof Error ? message.toString() : message);
31843282
}
31853283
exports.error = error;
31863284
/**
31873285
* Adds an warning issue
3188-
* @param message warning issue message
3286+
* @param message warning issue message. Errors will be converted to string via toString()
31893287
*/
31903288
function warning(message) {
3191-
command_1.issue('warning', message);
3289+
command_1.issue('warning', message instanceof Error ? message.toString() : message);
31923290
}
31933291
exports.warning = warning;
31943292
/**
@@ -3246,8 +3344,9 @@ exports.group = group;
32463344
* Saves state for current action, the state can only be retrieved by this action's post job execution.
32473345
*
32483346
* @param name name of the state to store
3249-
* @param value value to store
3347+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
32503348
*/
3349+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
32513350
function saveState(name, value) {
32523351
command_1.issueCommand('save-state', { name }, value);
32533352
}

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.

0 commit comments

Comments
 (0)