Skip to content

Commit 74c32a9

Browse files
authored
Update distribution
1 parent 800f06f commit 74c32a9

File tree

1 file changed

+83
-18
lines changed

1 file changed

+83
-18
lines changed

dist/index.js

+83-18
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
700700
};
701701
Object.defineProperty(exports, "__esModule", { value: true });
702702
const command_1 = __webpack_require__(241);
703+
const file_command_1 = __webpack_require__(717);
704+
const utils_1 = __webpack_require__(278);
703705
const os = __importStar(__webpack_require__(87));
704706
const path = __importStar(__webpack_require__(622));
705707
/**
@@ -726,9 +728,17 @@ var ExitCode;
726728
*/
727729
// eslint-disable-next-line @typescript-eslint/no-explicit-any
728730
function exportVariable(name, val) {
729-
const convertedVal = command_1.toCommandValue(val);
731+
const convertedVal = utils_1.toCommandValue(val);
730732
process.env[name] = convertedVal;
731-
command_1.issueCommand('set-env', { name }, convertedVal);
733+
const filePath = process.env['GITHUB_ENV'] || '';
734+
if (filePath) {
735+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
736+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
737+
file_command_1.issueCommand('ENV', commandValue);
738+
}
739+
else {
740+
command_1.issueCommand('set-env', { name }, convertedVal);
741+
}
732742
}
733743
exports.exportVariable = exportVariable;
734744
/**
@@ -744,7 +754,13 @@ exports.setSecret = setSecret;
744754
* @param inputPath
745755
*/
746756
function addPath(inputPath) {
747-
command_1.issueCommand('add-path', {}, inputPath);
757+
const filePath = process.env['GITHUB_PATH'] || '';
758+
if (filePath) {
759+
file_command_1.issueCommand('PATH', inputPath);
760+
}
761+
else {
762+
command_1.issueCommand('add-path', {}, inputPath);
763+
}
748764
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
749765
}
750766
exports.addPath = addPath;
@@ -1199,6 +1215,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
11991215
};
12001216
Object.defineProperty(exports, "__esModule", { value: true });
12011217
const os = __importStar(__webpack_require__(87));
1218+
const utils_1 = __webpack_require__(278);
12021219
/**
12031220
* Commands
12041221
*
@@ -1252,6 +1269,32 @@ class Command {
12521269
return cmdStr;
12531270
}
12541271
}
1272+
function escapeData(s) {
1273+
return utils_1.toCommandValue(s)
1274+
.replace(/%/g, '%25')
1275+
.replace(/\r/g, '%0D')
1276+
.replace(/\n/g, '%0A');
1277+
}
1278+
function escapeProperty(s) {
1279+
return utils_1.toCommandValue(s)
1280+
.replace(/%/g, '%25')
1281+
.replace(/\r/g, '%0D')
1282+
.replace(/\n/g, '%0A')
1283+
.replace(/:/g, '%3A')
1284+
.replace(/,/g, '%2C');
1285+
}
1286+
//# sourceMappingURL=command.js.map
1287+
1288+
/***/ }),
1289+
1290+
/***/ 278:
1291+
/***/ (function(__unusedmodule, exports) {
1292+
1293+
"use strict";
1294+
1295+
// We use any as a valid input type
1296+
/* eslint-disable @typescript-eslint/no-explicit-any */
1297+
Object.defineProperty(exports, "__esModule", { value: true });
12551298
/**
12561299
* Sanitizes an input into a string so it can be passed into issueCommand safely
12571300
* @param input input to sanitize into a string
@@ -1266,21 +1309,7 @@ function toCommandValue(input) {
12661309
return JSON.stringify(input);
12671310
}
12681311
exports.toCommandValue = toCommandValue;
1269-
function escapeData(s) {
1270-
return toCommandValue(s)
1271-
.replace(/%/g, '%25')
1272-
.replace(/\r/g, '%0D')
1273-
.replace(/\n/g, '%0A');
1274-
}
1275-
function escapeProperty(s) {
1276-
return toCommandValue(s)
1277-
.replace(/%/g, '%25')
1278-
.replace(/\r/g, '%0D')
1279-
.replace(/\n/g, '%0A')
1280-
.replace(/:/g, '%3A')
1281-
.replace(/,/g, '%2C');
1282-
}
1283-
//# sourceMappingURL=command.js.map
1312+
//# sourceMappingURL=utils.js.map
12841313

12851314
/***/ }),
12861315

@@ -2120,6 +2149,42 @@ function bytesToUuid(buf, offset) {
21202149
module.exports = bytesToUuid;
21212150

21222151

2152+
/***/ }),
2153+
2154+
/***/ 717:
2155+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
2156+
2157+
"use strict";
2158+
2159+
// For internal use, subject to change.
2160+
var __importStar = (this && this.__importStar) || function (mod) {
2161+
if (mod && mod.__esModule) return mod;
2162+
var result = {};
2163+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
2164+
result["default"] = mod;
2165+
return result;
2166+
};
2167+
Object.defineProperty(exports, "__esModule", { value: true });
2168+
// We use any as a valid input type
2169+
/* eslint-disable @typescript-eslint/no-explicit-any */
2170+
const fs = __importStar(__webpack_require__(747));
2171+
const os = __importStar(__webpack_require__(87));
2172+
const utils_1 = __webpack_require__(278);
2173+
function issueCommand(command, message) {
2174+
const filePath = process.env[`GITHUB_${command}`];
2175+
if (!filePath) {
2176+
throw new Error(`Unable to find environment variable for file command ${command}`);
2177+
}
2178+
if (!fs.existsSync(filePath)) {
2179+
throw new Error(`Missing file at path: ${filePath}`);
2180+
}
2181+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
2182+
encoding: 'utf8'
2183+
});
2184+
}
2185+
exports.issueCommand = issueCommand;
2186+
//# sourceMappingURL=file-command.js.map
2187+
21232188
/***/ }),
21242189

21252190
/***/ 747:

0 commit comments

Comments
 (0)