setup-php/lib/config.js

64 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2019-10-08 19:42:54 +07:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(require("./utils"));
/**
* Function to add custom ini values
*
* @param ini_values_csv
* @param os_version
*/
function addINIValues(ini_values_csv, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'win32':
return yield addINIValuesWindows(ini_values_csv);
case 'darwin':
case 'linux':
return yield addINIValuesUnix(ini_values_csv);
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', 'Add Config');
}
});
}
exports.addINIValues = addINIValues;
/**
* Add script to set custom ini values for unix
*
* @param ini_values_csv
*/
function addINIValuesUnix(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () {
let ini_values = yield utils.INIArray(ini_values_csv);
2019-10-11 06:11:25 +07:00
return '\necho "' + ini_values.join('\n') + '" >> $ini_file\n';
2019-10-08 19:42:54 +07:00
});
}
exports.addINIValuesUnix = addINIValuesUnix;
/**
* Add script to set custom ini values for windows
*
* @param ini_values_csv
*/
function addINIValuesWindows(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () {
let ini_values = yield utils.INIArray(ini_values_csv);
2019-10-11 06:11:25 +07:00
return ('Add-Content C:\\tools\\php\\php.ini "' + ini_values.join('\n') + '"\n');
2019-10-08 19:42:54 +07:00
});
}
exports.addINIValuesWindows = addINIValuesWindows;