Skip to content

Commit ffcd000

Browse files
Allow python-version-file to be a relative path (actions#431)
1 parent cf86e08 commit ffcd000

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

dist/setup/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -64546,18 +64546,18 @@ function cacheDependencies(cache, pythonVersion) {
6454664546
}
6454764547
function resolveVersionInput() {
6454864548
let version = core.getInput('python-version');
64549-
const versionFile = core.getInput('python-version-file');
64549+
let versionFile = core.getInput('python-version-file');
6455064550
if (version && versionFile) {
6455164551
core.warning('Both python-version and python-version-file inputs are specified, only python-version will be used');
6455264552
}
6455364553
if (version) {
6455464554
return version;
6455564555
}
64556-
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFile || '.python-version');
64557-
if (!fs_1.default.existsSync(versionFilePath)) {
64558-
throw new Error(`The specified python version file at: ${versionFilePath} does not exist`);
64556+
versionFile = versionFile || '.python-version';
64557+
if (!fs_1.default.existsSync(versionFile)) {
64558+
throw new Error(`The specified python version file at: ${versionFile} does not exist`);
6455964559
}
64560-
version = fs_1.default.readFileSync(versionFilePath, 'utf8');
64560+
version = fs_1.default.readFileSync(versionFile, 'utf8');
6456164561
core.info(`Resolved ${versionFile} as ${version}`);
6456264562
return version;
6456364563
}

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-python.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
2424

2525
function resolveVersionInput(): string {
2626
let version = core.getInput('python-version');
27-
const versionFile = core.getInput('python-version-file');
27+
let versionFile = core.getInput('python-version-file');
2828

2929
if (version && versionFile) {
3030
core.warning(
@@ -36,16 +36,13 @@ function resolveVersionInput(): string {
3636
return version;
3737
}
3838

39-
const versionFilePath = path.join(
40-
process.env.GITHUB_WORKSPACE!,
41-
versionFile || '.python-version'
42-
);
43-
if (!fs.existsSync(versionFilePath)) {
39+
versionFile = versionFile || '.python-version';
40+
if (!fs.existsSync(versionFile)) {
4441
throw new Error(
45-
`The specified python version file at: ${versionFilePath} does not exist`
42+
`The specified python version file at: ${versionFile} does not exist`
4643
);
4744
}
48-
version = fs.readFileSync(versionFilePath, 'utf8');
45+
version = fs.readFileSync(versionFile, 'utf8');
4946
core.info(`Resolved ${versionFile} as ${version}`);
5047

5148
return version;

0 commit comments

Comments
 (0)