mirror of
https://github.com/actions/setup-python.git
synced 2025-04-17 00:09:14 +08:00
Add error handling for Windows 'pip cache dir' execution
This commit is contained in:
parent
6ca8e8598f
commit
5e5f66be2b
19
dist/setup/index.js
vendored
19
dist/setup/index.js
vendored
|
@ -98893,24 +98893,25 @@ class PipCache extends cache_distributor_1.default {
|
||||||
}
|
}
|
||||||
getCacheGlobalDirectories() {
|
getCacheGlobalDirectories() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let exitCode = 1;
|
let exitCode = 0;
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
let stderr = '';
|
let stderr = '';
|
||||||
// Add temporary fix for Windows
|
// Add temporary fix for Windows
|
||||||
// On windows it is necessary to execute through an exec
|
// On Windows, it is necessary to execute through an exec
|
||||||
// because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2,
|
// because the getExecOutput gives a non-zero code or writes to stderr for pip 22.0.2,
|
||||||
// or spawn must be started with the shell option enabled for getExecOutput
|
// or spawn must be started with the shell option enabled for getExecOutput
|
||||||
// Related issue: https://github.com/actions/setup-python/issues/328
|
// Related issue: https://github.com/actions/setup-python/issues/328
|
||||||
if (utils_1.IS_WINDOWS) {
|
if (utils_1.IS_WINDOWS) {
|
||||||
const execPromisify = util_1.default.promisify(child_process.exec);
|
const execPromisify = util_1.default.promisify(child_process.exec);
|
||||||
({ stdout: stdout, stderr: stderr } = yield execPromisify('pip cache dir'));
|
try {
|
||||||
|
({ stdout, stderr } = yield execPromisify('pip cache dir'));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
exitCode = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
({
|
({ stdout, stderr, exitCode } = yield exec.getExecOutput('pip cache dir'));
|
||||||
stdout: stdout,
|
|
||||||
stderr: stderr,
|
|
||||||
exitCode: exitCode
|
|
||||||
} = yield exec.getExecOutput('pip cache dir'));
|
|
||||||
}
|
}
|
||||||
if (exitCode && stderr) {
|
if (exitCode && stderr) {
|
||||||
throw new Error(`Could not get cache folder path for pip package manager`);
|
throw new Error(`Could not get cache folder path for pip package manager`);
|
||||||
|
|
|
@ -21,24 +21,24 @@ class PipCache extends CacheDistributor {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getCacheGlobalDirectories() {
|
protected async getCacheGlobalDirectories() {
|
||||||
let exitCode = 1;
|
let exitCode = 0;
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
let stderr = '';
|
let stderr = '';
|
||||||
|
|
||||||
// Add temporary fix for Windows
|
// Add temporary fix for Windows
|
||||||
// On windows it is necessary to execute through an exec
|
// On Windows, it is necessary to execute through an exec
|
||||||
// because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2,
|
// because the getExecOutput gives a non-zero code or writes to stderr for pip 22.0.2,
|
||||||
// or spawn must be started with the shell option enabled for getExecOutput
|
// or spawn must be started with the shell option enabled for getExecOutput
|
||||||
// Related issue: https://github.com/actions/setup-python/issues/328
|
// Related issue: https://github.com/actions/setup-python/issues/328
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
const execPromisify = utils.promisify(child_process.exec);
|
const execPromisify = utils.promisify(child_process.exec);
|
||||||
({stdout: stdout, stderr: stderr} = await execPromisify('pip cache dir'));
|
try {
|
||||||
|
({stdout, stderr} = await execPromisify('pip cache dir'));
|
||||||
|
} catch (err) {
|
||||||
|
exitCode = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
({
|
({stdout, stderr, exitCode} = await exec.getExecOutput('pip cache dir'));
|
||||||
stdout: stdout,
|
|
||||||
stderr: stderr,
|
|
||||||
exitCode: exitCode
|
|
||||||
} = await exec.getExecOutput('pip cache dir'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exitCode && stderr) {
|
if (exitCode && stderr) {
|
||||||
|
|
Loading…
Reference in a new issue