Skip to content

Commit

Permalink
add archname to PERL5LIB (#1327)
Browse files Browse the repository at this point in the history
* add archname to PERL5LIB

* npm run format
  • Loading branch information
shogo82148 committed Nov 12, 2022
1 parent 5919fe6 commit cae9fc4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cpan-installer.ts
Expand Up @@ -82,7 +82,10 @@ export async function install(opt: Options): Promise<void> {

// configure environment values
core.addPath(path.join(cachePath, "bin"));
core.exportVariable("PERL5LIB", path.join(cachePath, "lib", "perl5") + path.delimiter + process.env["PERL5LIB"]);
const archName = await getArchName(opt);
const libPath = path.join(cachePath, "lib", "perl5");
const libArchPath = path.join(cachePath, "lib", "perl5", archName);
core.exportVariable("PERL5LIB", libPath + path.delimiter + libArchPath + path.delimiter + process.env["PERL5LIB"]);

if (opt.enable_modules_cache) {
// save cache
Expand Down Expand Up @@ -219,6 +222,13 @@ async function installWithCarton(opt: Options): Promise<void> {
}
}

// getArchName gets the arch name such as x86_64-linux, darwin-thread-multi-2level, etc.
async function getArchName(opt: Options): Promise<string> {
const perl = path.join(opt.toolPath, "bin", "perl");
const out = await exec.getExecOutput(perl, ["-MConfig", "-E", "print $Config{archname}"]);
return out.stdout;
}

async function exists(path: string): Promise<boolean> {
return new Promise((resolve, reject) => {
fs.stat(path, (err) => {
Expand Down

0 comments on commit cae9fc4

Please sign in to comment.