mirror of
https://github.com/actions/setup-python.git
synced 2025-04-20 12:03:29 +00:00
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
![]() |
import * as fs from 'fs';
|
||
|
import * as path from 'path';
|
||
|
|
||
|
export const IS_WINDOWS = process.platform === 'win32';
|
||
|
export const IS_LINUX = process.platform === 'linux';
|
||
|
|
||
|
export interface IPyPyManifestAsset {
|
||
|
filename: string;
|
||
|
arch: string;
|
||
|
platform: string;
|
||
|
download_url: string;
|
||
|
}
|
||
|
|
||
|
export interface IPyPyManifestRelease {
|
||
|
pypy_version: string;
|
||
|
python_version: string;
|
||
|
stable: boolean;
|
||
|
latest_pypy: boolean;
|
||
|
files: IPyPyManifestAsset[];
|
||
|
}
|
||
|
|
||
|
/** create Symlinks for downloaded PyPy
|
||
|
* It should be executed only for downloaded versions in runtime, because
|
||
|
* toolcache versions have this setup.
|
||
|
*/
|
||
|
export function createSymlinkInFolder(
|
||
|
folderPath: string,
|
||
|
sourceName: string,
|
||
|
targetName: string,
|
||
|
setExecutable = false
|
||
|
) {
|
||
|
const sourcePath = path.join(folderPath, sourceName);
|
||
|
const targetPath = path.join(folderPath, targetName);
|
||
|
if (fs.existsSync(targetPath)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
fs.symlinkSync(sourcePath, targetPath);
|
||
|
if (!IS_WINDOWS && setExecutable) {
|
||
|
fs.chmodSync(targetPath, '755');
|
||
|
}
|
||
|
}
|