2019-10-08 19:42:54 +07:00
|
|
|
import * as utils from './utils';
|
|
|
|
|
2019-11-24 03:34:12 +07:00
|
|
|
/**
|
|
|
|
* Add script to set custom ini values for unix
|
|
|
|
*
|
|
|
|
* @param ini_values_csv
|
|
|
|
*/
|
|
|
|
export async function addINIValuesUnix(
|
|
|
|
ini_values_csv: string
|
|
|
|
): Promise<string> {
|
2019-12-27 08:26:49 +07:00
|
|
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
2020-06-20 07:55:19 +07:00
|
|
|
let script = '';
|
2020-05-08 07:11:00 +07:00
|
|
|
await utils.asyncForEach(ini_values, async function (line: string) {
|
2019-11-24 03:34:12 +07:00
|
|
|
script +=
|
2020-06-20 07:55:19 +07:00
|
|
|
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
2019-11-24 03:34:12 +07:00
|
|
|
});
|
2020-12-02 07:20:56 +07:00
|
|
|
return (
|
|
|
|
'echo "' +
|
|
|
|
ini_values.join('\n') +
|
2020-12-17 22:19:20 +07:00
|
|
|
'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' +
|
2020-12-02 07:20:56 +07:00
|
|
|
script
|
|
|
|
);
|
2019-11-24 03:34:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add script to set custom ini values for windows
|
|
|
|
*
|
|
|
|
* @param ini_values_csv
|
|
|
|
*/
|
|
|
|
export async function addINIValuesWindows(
|
|
|
|
ini_values_csv: string
|
|
|
|
): Promise<string> {
|
2019-12-27 08:26:49 +07:00
|
|
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
2019-11-24 03:34:12 +07:00
|
|
|
let script = '\n';
|
2020-05-08 07:11:00 +07:00
|
|
|
await utils.asyncForEach(ini_values, async function (line: string) {
|
2019-11-24 03:34:12 +07:00
|
|
|
script +=
|
|
|
|
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
|
|
|
|
});
|
|
|
|
return (
|
2020-05-17 05:09:04 +07:00
|
|
|
'Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script
|
2019-11-24 03:34:12 +07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-08 19:42:54 +07:00
|
|
|
/**
|
|
|
|
* Function to add custom ini values
|
|
|
|
*
|
|
|
|
* @param ini_values_csv
|
2022-01-29 06:59:58 +07:00
|
|
|
* @param os
|
2020-03-12 09:27:40 +07:00
|
|
|
* @param no_step
|
2019-10-08 19:42:54 +07:00
|
|
|
*/
|
2019-10-17 03:11:13 +07:00
|
|
|
export async function addINIValues(
|
|
|
|
ini_values_csv: string,
|
2022-01-29 06:59:58 +07:00
|
|
|
os: string,
|
2019-10-17 03:11:13 +07:00
|
|
|
no_step = false
|
|
|
|
): Promise<string> {
|
2019-11-24 03:34:12 +07:00
|
|
|
let script = '\n';
|
2019-10-17 03:11:13 +07:00
|
|
|
switch (no_step) {
|
|
|
|
case true:
|
|
|
|
script +=
|
2022-01-29 06:59:58 +07:00
|
|
|
(await utils.stepLog('Add php.ini values', os)) +
|
|
|
|
(await utils.suppressOutput(os)) +
|
2019-10-17 03:11:13 +07:00
|
|
|
'\n';
|
|
|
|
break;
|
|
|
|
case false:
|
|
|
|
default:
|
2022-01-29 06:59:58 +07:00
|
|
|
script += (await utils.stepLog('Add php.ini values', os)) + '\n';
|
2019-10-17 03:11:13 +07:00
|
|
|
break;
|
|
|
|
}
|
2022-01-29 06:59:58 +07:00
|
|
|
switch (os) {
|
2019-10-08 19:42:54 +07:00
|
|
|
case 'win32':
|
2019-10-17 03:11:13 +07:00
|
|
|
return script + (await addINIValuesWindows(ini_values_csv));
|
2019-10-08 19:42:54 +07:00
|
|
|
case 'darwin':
|
|
|
|
case 'linux':
|
2019-10-17 03:11:13 +07:00
|
|
|
return script + (await addINIValuesUnix(ini_values_csv));
|
2019-10-08 19:42:54 +07:00
|
|
|
default:
|
|
|
|
return await utils.log(
|
2022-01-29 06:59:58 +07:00
|
|
|
'Platform ' + os + ' is not supported',
|
|
|
|
os,
|
2019-10-17 03:11:13 +07:00
|
|
|
'error'
|
2019-10-08 19:42:54 +07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|