Skip to content

Commit d465bf7

Browse files
committed
Built setup-env & added changes for dist/index.js
1 parent 4079671 commit d465bf7

File tree

1 file changed

+84
-19
lines changed

1 file changed

+84
-19
lines changed

setup-env/dist/index.js

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,32 @@ function onceStrict (fn) {
151151
}
152152

153153

154+
/***/ }),
155+
156+
/***/ 82:
157+
/***/ (function(__unusedmodule, exports) {
158+
159+
"use strict";
160+
161+
// We use any as a valid input type
162+
/* eslint-disable @typescript-eslint/no-explicit-any */
163+
Object.defineProperty(exports, "__esModule", { value: true });
164+
/**
165+
* Sanitizes an input into a string so it can be passed into issueCommand safely
166+
* @param input input to sanitize into a string
167+
*/
168+
function toCommandValue(input) {
169+
if (input === null || input === undefined) {
170+
return '';
171+
}
172+
else if (typeof input === 'string' || input instanceof String) {
173+
return input;
174+
}
175+
return JSON.stringify(input);
176+
}
177+
exports.toCommandValue = toCommandValue;
178+
//# sourceMappingURL=utils.js.map
179+
154180
/***/ }),
155181

156182
/***/ 87:
@@ -160,6 +186,42 @@ module.exports = require("os");
160186

161187
/***/ }),
162188

189+
/***/ 102:
190+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
191+
192+
"use strict";
193+
194+
// For internal use, subject to change.
195+
var __importStar = (this && this.__importStar) || function (mod) {
196+
if (mod && mod.__esModule) return mod;
197+
var result = {};
198+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
199+
result["default"] = mod;
200+
return result;
201+
};
202+
Object.defineProperty(exports, "__esModule", { value: true });
203+
// We use any as a valid input type
204+
/* eslint-disable @typescript-eslint/no-explicit-any */
205+
const fs = __importStar(__webpack_require__(747));
206+
const os = __importStar(__webpack_require__(87));
207+
const utils_1 = __webpack_require__(82);
208+
function issueCommand(command, message) {
209+
const filePath = process.env[`GITHUB_${command}`];
210+
if (!filePath) {
211+
throw new Error(`Unable to find environment variable for file command ${command}`);
212+
}
213+
if (!fs.existsSync(filePath)) {
214+
throw new Error(`Missing file at path: ${filePath}`);
215+
}
216+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
217+
encoding: 'utf8'
218+
});
219+
}
220+
exports.issueCommand = issueCommand;
221+
//# sourceMappingURL=file-command.js.map
222+
223+
/***/ }),
224+
163225
/***/ 127:
164226
/***/ (function(__unusedmodule, exports, __webpack_require__) {
165227

@@ -1261,6 +1323,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
12611323
};
12621324
Object.defineProperty(exports, "__esModule", { value: true });
12631325
const os = __importStar(__webpack_require__(87));
1326+
const utils_1 = __webpack_require__(82);
12641327
/**
12651328
* Commands
12661329
*
@@ -1314,28 +1377,14 @@ class Command {
13141377
return cmdStr;
13151378
}
13161379
}
1317-
/**
1318-
* Sanitizes an input into a string so it can be passed into issueCommand safely
1319-
* @param input input to sanitize into a string
1320-
*/
1321-
function toCommandValue(input) {
1322-
if (input === null || input === undefined) {
1323-
return '';
1324-
}
1325-
else if (typeof input === 'string' || input instanceof String) {
1326-
return input;
1327-
}
1328-
return JSON.stringify(input);
1329-
}
1330-
exports.toCommandValue = toCommandValue;
13311380
function escapeData(s) {
1332-
return toCommandValue(s)
1381+
return utils_1.toCommandValue(s)
13331382
.replace(/%/g, '%25')
13341383
.replace(/\r/g, '%0D')
13351384
.replace(/\n/g, '%0A');
13361385
}
13371386
function escapeProperty(s) {
1338-
return toCommandValue(s)
1387+
return utils_1.toCommandValue(s)
13391388
.replace(/%/g, '%25')
13401389
.replace(/\r/g, '%0D')
13411390
.replace(/\n/g, '%0A')
@@ -3309,6 +3358,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
33093358
};
33103359
Object.defineProperty(exports, "__esModule", { value: true });
33113360
const command_1 = __webpack_require__(431);
3361+
const file_command_1 = __webpack_require__(102);
3362+
const utils_1 = __webpack_require__(82);
33123363
const os = __importStar(__webpack_require__(87));
33133364
const path = __importStar(__webpack_require__(622));
33143365
/**
@@ -3335,9 +3386,17 @@ var ExitCode;
33353386
*/
33363387
// eslint-disable-next-line @typescript-eslint/no-explicit-any
33373388
function exportVariable(name, val) {
3338-
const convertedVal = command_1.toCommandValue(val);
3389+
const convertedVal = utils_1.toCommandValue(val);
33393390
process.env[name] = convertedVal;
3340-
command_1.issueCommand('set-env', { name }, convertedVal);
3391+
const filePath = process.env['GITHUB_ENV'] || '';
3392+
if (filePath) {
3393+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
3394+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
3395+
file_command_1.issueCommand('ENV', commandValue);
3396+
}
3397+
else {
3398+
command_1.issueCommand('set-env', { name }, convertedVal);
3399+
}
33413400
}
33423401
exports.exportVariable = exportVariable;
33433402
/**
@@ -3353,7 +3412,13 @@ exports.setSecret = setSecret;
33533412
* @param inputPath
33543413
*/
33553414
function addPath(inputPath) {
3356-
command_1.issueCommand('add-path', {}, inputPath);
3415+
const filePath = process.env['GITHUB_PATH'] || '';
3416+
if (filePath) {
3417+
file_command_1.issueCommand('PATH', inputPath);
3418+
}
3419+
else {
3420+
command_1.issueCommand('add-path', {}, inputPath);
3421+
}
33573422
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
33583423
}
33593424
exports.addPath = addPath;

0 commit comments

Comments
 (0)