remove direct dependency on @actions/io

This commit is contained in:
Robert
2020-08-07 17:46:46 +01:00
parent 8608105240
commit de0b59097a
14 changed files with 20 additions and 39 deletions

14
lib/config-utils.js generated
View File

@@ -8,7 +8,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io"));
const fs = __importStar(require("fs"));
const yaml = __importStar(require("js-yaml"));
const path = __importStar(require("path"));
@@ -521,17 +520,11 @@ async function getRemoteConfig(configFile) {
}
return yaml.safeLoad(Buffer.from(fileContents, 'base64').toString('binary'));
}
/**
* Get the directory where the parsed config will be stored.
*/
function getPathToParsedConfigFolder() {
return util.getRequiredEnvParam('RUNNER_TEMP');
}
/**
* Get the file path where the parsed config will be stored.
*/
function getPathToParsedConfigFile() {
return path.join(getPathToParsedConfigFolder(), 'config');
return path.join(util.getRequiredEnvParam('RUNNER_TEMP'), 'config');
}
exports.getPathToParsedConfigFile = getPathToParsedConfigFile;
/**
@@ -539,8 +532,9 @@ exports.getPathToParsedConfigFile = getPathToParsedConfigFile;
*/
async function saveConfig(config) {
const configString = JSON.stringify(config);
await io.mkdirP(getPathToParsedConfigFolder());
fs.writeFileSync(getPathToParsedConfigFile(), configString, 'utf8');
const configFile = getPathToParsedConfigFile();
fs.mkdirSync(path.dirname(configFile), { recursive: true });
fs.writeFileSync(configFile, configString, 'utf8');
core.debug('Saved config:');
core.debug(configString);
}