Permalink
Cannot retrieve contributors at this time
58 lines (58 sloc)
2.51 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@actions/core/lib/file-command.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// For internal use, subject to change. | |
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | |
if (k2 === undefined) k2 = k; | |
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | |
}) : (function(o, m, k, k2) { | |
if (k2 === undefined) k2 = k; | |
o[k2] = m[k]; | |
})); | |
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | |
Object.defineProperty(o, "default", { enumerable: true, value: v }); | |
}) : function(o, v) { | |
o["default"] = v; | |
}); | |
var __importStar = (this && this.__importStar) || function (mod) { | |
if (mod && mod.__esModule) return mod; | |
var result = {}; | |
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | |
__setModuleDefault(result, mod); | |
return result; | |
}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; | |
// We use any as a valid input type | |
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
const fs = __importStar(require("fs")); | |
const os = __importStar(require("os")); | |
const uuid_1 = require("uuid"); | |
const utils_1 = require("./utils"); | |
function issueFileCommand(command, message) { | |
const filePath = process.env[`GITHUB_${command}`]; | |
if (!filePath) { | |
throw new Error(`Unable to find environment variable for file command ${command}`); | |
} | |
if (!fs.existsSync(filePath)) { | |
throw new Error(`Missing file at path: ${filePath}`); | |
} | |
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { | |
encoding: 'utf8' | |
}); | |
} | |
exports.issueFileCommand = issueFileCommand; | |
function prepareKeyValueMessage(key, value) { | |
const delimiter = `ghadelimiter_${uuid_1.v4()}`; | |
const convertedValue = utils_1.toCommandValue(value); | |
// These should realistically never happen, but just in case someone finds a | |
// way to exploit uuid generation let's not allow keys or values that contain | |
// the delimiter. | |
if (key.includes(delimiter)) { | |
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); | |
} | |
if (convertedValue.includes(delimiter)) { | |
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); | |
} | |
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; | |
} | |
exports.prepareKeyValueMessage = prepareKeyValueMessage; | |
//# sourceMappingURL=file-command.js.map |