mirror of https://github.com/actions/toolkit
tool-cache: make extract functions quiet by default and more verbose if `core.isDebug` is set (#206)
* tool-cache: make unzip and 7z extract quiet by default This avoids spamming the log when unzipping large archives. * tool-cache: make tar, unzip and 7z verbose when `core.isDebug` Make the extract function print the list of extracted file if the action is run in debug mode.pull/437/head
parent
4e734dc4c1
commit
57d20b4db4
|
@ -334,7 +334,7 @@ describe('@actions/tool-cache', function() {
|
||||||
.readFileSync(path.join(tempDir, 'mock7zr-args.txt'))
|
.readFileSync(path.join(tempDir, 'mock7zr-args.txt'))
|
||||||
.toString()
|
.toString()
|
||||||
.trim()
|
.trim()
|
||||||
).toBe(`x -bb1 -bd -sccUTF-8 ${_7zFile}`)
|
).toBe(`x -bb0 -bd -sccUTF-8 ${_7zFile}`)
|
||||||
expect(fs.existsSync(path.join(extPath, 'file.txt'))).toBeTruthy()
|
expect(fs.existsSync(path.join(extPath, 'file.txt'))).toBeTruthy()
|
||||||
expect(
|
expect(
|
||||||
fs.existsSync(path.join(extPath, 'file-with-ç-character.txt'))
|
fs.existsSync(path.join(extPath, 'file-with-ç-character.txt'))
|
||||||
|
|
|
@ -144,9 +144,10 @@ export async function extract7z(
|
||||||
process.chdir(dest)
|
process.chdir(dest)
|
||||||
if (_7zPath) {
|
if (_7zPath) {
|
||||||
try {
|
try {
|
||||||
|
const logLevel = core.isDebug() ? '-bb1' : '-bb0'
|
||||||
const args: string[] = [
|
const args: string[] = [
|
||||||
'x', // eXtract files with full paths
|
'x', // eXtract files with full paths
|
||||||
'-bb1', // -bb[0-3] : set output log level
|
logLevel, // -bb[0-3] : set output log level
|
||||||
'-bd', // disable progress indicator
|
'-bd', // disable progress indicator
|
||||||
'-sccUTF-8', // set charset for for console input/output
|
'-sccUTF-8', // set charset for for console input/output
|
||||||
file
|
file
|
||||||
|
@ -227,6 +228,10 @@ export async function extractTar(
|
||||||
// Initialize args
|
// Initialize args
|
||||||
const args = [flags]
|
const args = [flags]
|
||||||
|
|
||||||
|
if (core.isDebug() && !flags.includes('v')) {
|
||||||
|
args.push('-v')
|
||||||
|
}
|
||||||
|
|
||||||
let destArg = dest
|
let destArg = dest
|
||||||
let fileArg = file
|
let fileArg = file
|
||||||
if (IS_WINDOWS && isGnuTar) {
|
if (IS_WINDOWS && isGnuTar) {
|
||||||
|
@ -295,7 +300,11 @@ async function extractZipWin(file: string, dest: string): Promise<void> {
|
||||||
|
|
||||||
async function extractZipNix(file: string, dest: string): Promise<void> {
|
async function extractZipNix(file: string, dest: string): Promise<void> {
|
||||||
const unzipPath = await io.which('unzip', true)
|
const unzipPath = await io.which('unzip', true)
|
||||||
await exec(`"${unzipPath}"`, [file], {cwd: dest})
|
const args = [file]
|
||||||
|
if (!core.isDebug()) {
|
||||||
|
args.unshift('-q')
|
||||||
|
}
|
||||||
|
await exec(`"${unzipPath}"`, args, {cwd: dest})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue