Skip to content

Commit 2ce216d

Browse files
authored
Merge pull request #86 from peter-evans/update-distribution
Update distribution
2 parents 69afb15 + cb42e06 commit 2ce216d

File tree

1 file changed

+84
-19
lines changed

1 file changed

+84
-19
lines changed

dist/index.js

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
643643
};
644644
Object.defineProperty(exports, "__esModule", ({ value: true }));
645645
const os = __importStar(__webpack_require__(87));
646+
const utils_1 = __webpack_require__(278);
646647
/**
647648
* Commands
648649
*
@@ -696,28 +697,14 @@ class Command {
696697
return cmdStr;
697698
}
698699
}
699-
/**
700-
* Sanitizes an input into a string so it can be passed into issueCommand safely
701-
* @param input input to sanitize into a string
702-
*/
703-
function toCommandValue(input) {
704-
if (input === null || input === undefined) {
705-
return '';
706-
}
707-
else if (typeof input === 'string' || input instanceof String) {
708-
return input;
709-
}
710-
return JSON.stringify(input);
711-
}
712-
exports.toCommandValue = toCommandValue;
713700
function escapeData(s) {
714-
return toCommandValue(s)
701+
return utils_1.toCommandValue(s)
715702
.replace(/%/g, '%25')
716703
.replace(/\r/g, '%0D')
717704
.replace(/\n/g, '%0A');
718705
}
719706
function escapeProperty(s) {
720-
return toCommandValue(s)
707+
return utils_1.toCommandValue(s)
721708
.replace(/%/g, '%25')
722709
.replace(/\r/g, '%0D')
723710
.replace(/\n/g, '%0A')
@@ -751,6 +738,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
751738
};
752739
Object.defineProperty(exports, "__esModule", ({ value: true }));
753740
const command_1 = __webpack_require__(351);
741+
const file_command_1 = __webpack_require__(717);
742+
const utils_1 = __webpack_require__(278);
754743
const os = __importStar(__webpack_require__(87));
755744
const path = __importStar(__webpack_require__(622));
756745
/**
@@ -777,9 +766,17 @@ var ExitCode;
777766
*/
778767
// eslint-disable-next-line @typescript-eslint/no-explicit-any
779768
function exportVariable(name, val) {
780-
const convertedVal = command_1.toCommandValue(val);
769+
const convertedVal = utils_1.toCommandValue(val);
781770
process.env[name] = convertedVal;
782-
command_1.issueCommand('set-env', { name }, convertedVal);
771+
const filePath = process.env['GITHUB_ENV'] || '';
772+
if (filePath) {
773+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
774+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
775+
file_command_1.issueCommand('ENV', commandValue);
776+
}
777+
else {
778+
command_1.issueCommand('set-env', { name }, convertedVal);
779+
}
783780
}
784781
exports.exportVariable = exportVariable;
785782
/**
@@ -795,7 +792,13 @@ exports.setSecret = setSecret;
795792
* @param inputPath
796793
*/
797794
function addPath(inputPath) {
798-
command_1.issueCommand('add-path', {}, inputPath);
795+
const filePath = process.env['GITHUB_PATH'] || '';
796+
if (filePath) {
797+
file_command_1.issueCommand('PATH', inputPath);
798+
}
799+
else {
800+
command_1.issueCommand('add-path', {}, inputPath);
801+
}
799802
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
800803
}
801804
exports.addPath = addPath;
@@ -957,6 +960,68 @@ exports.getState = getState;
957960

958961
/***/ }),
959962

963+
/***/ 717:
964+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
965+
966+
"use strict";
967+
968+
// For internal use, subject to change.
969+
var __importStar = (this && this.__importStar) || function (mod) {
970+
if (mod && mod.__esModule) return mod;
971+
var result = {};
972+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
973+
result["default"] = mod;
974+
return result;
975+
};
976+
Object.defineProperty(exports, "__esModule", ({ value: true }));
977+
// We use any as a valid input type
978+
/* eslint-disable @typescript-eslint/no-explicit-any */
979+
const fs = __importStar(__webpack_require__(747));
980+
const os = __importStar(__webpack_require__(87));
981+
const utils_1 = __webpack_require__(278);
982+
function issueCommand(command, message) {
983+
const filePath = process.env[`GITHUB_${command}`];
984+
if (!filePath) {
985+
throw new Error(`Unable to find environment variable for file command ${command}`);
986+
}
987+
if (!fs.existsSync(filePath)) {
988+
throw new Error(`Missing file at path: ${filePath}`);
989+
}
990+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
991+
encoding: 'utf8'
992+
});
993+
}
994+
exports.issueCommand = issueCommand;
995+
//# sourceMappingURL=file-command.js.map
996+
997+
/***/ }),
998+
999+
/***/ 278:
1000+
/***/ ((__unused_webpack_module, exports) => {
1001+
1002+
"use strict";
1003+
1004+
// We use any as a valid input type
1005+
/* eslint-disable @typescript-eslint/no-explicit-any */
1006+
Object.defineProperty(exports, "__esModule", ({ value: true }));
1007+
/**
1008+
* Sanitizes an input into a string so it can be passed into issueCommand safely
1009+
* @param input input to sanitize into a string
1010+
*/
1011+
function toCommandValue(input) {
1012+
if (input === null || input === undefined) {
1013+
return '';
1014+
}
1015+
else if (typeof input === 'string' || input instanceof String) {
1016+
return input;
1017+
}
1018+
return JSON.stringify(input);
1019+
}
1020+
exports.toCommandValue = toCommandValue;
1021+
//# sourceMappingURL=utils.js.map
1022+
1023+
/***/ }),
1024+
9601025
/***/ 53:
9611026
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9621027

0 commit comments

Comments
 (0)