mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-08 05:44:07 +07:00
Remove unnecessary writing of scripts to RUNNER_TOOL_CACHE
This commit is contained in:
@ -5,6 +5,8 @@ import * as coverage from './coverage';
|
||||
import * as extensions from './extensions';
|
||||
import * as tools from './tools';
|
||||
import * as utils from './utils';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
/**
|
||||
* Build the script
|
||||
@ -25,8 +27,8 @@ export async function getScript(
|
||||
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
||||
const coverage_driver: string = await utils.getInput('coverage', false);
|
||||
const tools_csv: string = await utils.getInput('tools', false);
|
||||
|
||||
let script: string = await utils.readFile(filename, 'src/scripts');
|
||||
const script_path = path.join(__dirname, '../src/scripts', filename);
|
||||
let script: string = fs.readFileSync(script_path, 'utf8');
|
||||
if (extension_csv) {
|
||||
script += await extensions.addExtension(extension_csv, version, os_version);
|
||||
}
|
||||
@ -40,7 +42,9 @@ export async function getScript(
|
||||
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os_version));
|
||||
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os_version));
|
||||
|
||||
return await utils.writeScript(filename, script);
|
||||
fs.writeFileSync(script_path, script, {mode: 0o755});
|
||||
|
||||
return script_path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,6 @@
|
||||
import * as utils from './utils';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
type RS = Record<string, string>;
|
||||
type RSRS = Record<string, RS>;
|
||||
@ -416,7 +418,8 @@ export async function getData(
|
||||
php_version: string,
|
||||
os_version: string
|
||||
): Promise<RS> {
|
||||
const json_file: string = await utils.readFile('tools.json', 'src/configs');
|
||||
const json_file_path = path.join(__dirname, '../src/configs/tools.json');
|
||||
const json_file: string = fs.readFileSync(json_file_path, 'utf8');
|
||||
const json_objects: RSRS = JSON.parse(json_file);
|
||||
release = release.replace(/\s+/g, '');
|
||||
const parts: string[] = release.split(':');
|
||||
|
33
src/utils.ts
33
src/utils.ts
@ -1,5 +1,4 @@
|
||||
import {IncomingMessage, OutgoingHttpHeaders} from 'http';
|
||||
import * as fs from 'fs';
|
||||
import * as https from 'https';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
@ -251,38 +250,6 @@ export async function addLog(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the scripts
|
||||
*
|
||||
* @param filename
|
||||
* @param directory
|
||||
*/
|
||||
export async function readFile(
|
||||
filename: string,
|
||||
directory: string
|
||||
): Promise<string> {
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../' + directory, filename),
|
||||
'utf8'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write final script which runs
|
||||
*
|
||||
* @param filename
|
||||
* @param script
|
||||
*/
|
||||
export async function writeScript(
|
||||
filename: string,
|
||||
script: string
|
||||
): Promise<string> {
|
||||
const runner_dir: string = await getInput('RUNNER_TOOL_CACHE', false);
|
||||
const script_path: string = path.join(runner_dir, filename);
|
||||
fs.writeFileSync(script_path, script, {mode: 0o755});
|
||||
return script_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to break extension csv into an array
|
||||
*
|
||||
|
Reference in New Issue
Block a user