Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
if (_7zPath) {
try {
const args = [
'x',
'-bb1',
'-bd',
'-sccUTF-8',
file
];
const options = {
silent: true
};
yield exec_1.exec(`"${_7zPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
else {
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
if (_7zPath) {
try {
const args = [
'x',
'-bb1',
'-bd',
'-sccUTF-8',
file
];
const options = {
silent: true
};
yield exec_1.exec(`"${_7zPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
else {
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
// check the os version and run the respective script
let script_path = '';
switch (os_version) {
case 'darwin':
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
break;
case 'linux': {
const pecl: string = await utils.getInput('pecl', false);
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
break;
}
case 'win32':
script_path = await build('win32.ps1', version, os_version);
await exec(
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
);
break;
}
await matchers.addMatchers();
} catch (error) {
core.setFailed(error.message);
}
}
export async function run(): Promise {
try {
const os_version: string = process.platform;
let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version : version + '.0';
// check the os version and run the respective script
let script_path = '';
switch (os_version) {
case 'darwin':
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
break;
case 'linux': {
const pecl: string = await utils.getInput('pecl', false);
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
break;
}
case 'win32':
script_path = await build('win32.ps1', version, os_version);
await exec(
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
);
break;
}
await matchers.addMatchers();
} catch (error) {
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '')
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`
// run powershell
const powershellPath = await io.which('powershell')
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
]
await exec(`"${powershellPath}"`, args)
}
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
if (_7zPath) {
try {
const args = [
'x',
'-bb1',
'-bd',
'-sccUTF-8',
file
];
const options = {
silent: true
};
yield exec_1.exec(`"${_7zPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
else {
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
async function extractZipNix(file: string, dest: string): Promise {
const unzipPath = await io.which('unzip')
await exec(`"${unzipPath}"`, [file], {cwd: dest})
}
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
const options = {
silent: true
};
try {
const powershellPath = yield io.which('powershell', true);
yield exec_1.exec(`"${powershellPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
return dest;
});
}
const args: string[] = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
]
const options: ExecOptions = {
silent: true
}
try {
const powershellPath: string = await io.which('powershell', true)
await exec(`"${powershellPath}"`, args, options)
} finally {
process.chdir(originalCwd)
}
}
return dest
}