* Extract a .7z file * * @param file path to the .7z file * @param dest destination directory. Optional. * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this * problem. If your .7z archive contains very long paths, you can pass the path
(file, dest, _7zPath)
| 4047 | * @returns path to the destination directory |
| 4048 | */ |
| 4049 | function extract7z(file, dest, _7zPath) { |
| 4050 | return __awaiter(this, void 0, void 0, function* () { |
| 4051 | assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); |
| 4052 | assert_1.ok(file, 'parameter "file" is required'); |
| 4053 | dest = yield _createExtractFolder(dest); |
| 4054 | const originalCwd = process.cwd(); |
| 4055 | process.chdir(dest); |
| 4056 | if (_7zPath) { |
| 4057 | try { |
| 4058 | const logLevel = core.isDebug() ? '-bb1' : '-bb0'; |
| 4059 | const args = [ |
| 4060 | 'x', |
| 4061 | logLevel, |
| 4062 | '-bd', |
| 4063 | '-sccUTF-8', |
| 4064 | file |
| 4065 | ]; |
| 4066 | const options = { |
| 4067 | silent: true |
| 4068 | }; |
| 4069 | yield exec_1.exec(`"${_7zPath}"`, args, options); |
| 4070 | } |
| 4071 | finally { |
| 4072 | process.chdir(originalCwd); |
| 4073 | } |
| 4074 | } |
| 4075 | else { |
| 4076 | const escapedScript = path |
| 4077 | .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') |
| 4078 | .replace(/'/g, "''") |
| 4079 | .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines |
| 4080 | const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); |
| 4081 | const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); |
| 4082 | const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; |
| 4083 | const args = [ |
| 4084 | '-NoLogo', |
| 4085 | '-Sta', |
| 4086 | '-NoProfile', |
| 4087 | '-NonInteractive', |
| 4088 | '-ExecutionPolicy', |
| 4089 | 'Unrestricted', |
| 4090 | '-Command', |
| 4091 | command |
| 4092 | ]; |
| 4093 | const options = { |
| 4094 | silent: true |
| 4095 | }; |
| 4096 | try { |
| 4097 | const powershellPath = yield io.which('powershell', true); |
| 4098 | yield exec_1.exec(`"${powershellPath}"`, args, options); |
| 4099 | } |
| 4100 | finally { |
| 4101 | process.chdir(originalCwd); |
| 4102 | } |
| 4103 | } |
| 4104 | return dest; |
| 4105 | }); |
| 4106 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…