Skip to content

Commit

Permalink
Move main into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMayes committed Apr 1, 2024
1 parent 672fbb5 commit 4d97c22
Show file tree
Hide file tree
Showing 7 changed files with 6,479 additions and 6,556 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ outputs:

runs:
using: "node20"
main: "dist/index.js"
main: "dist/main.js"
1 change: 0 additions & 1 deletion dist/index.js.map

This file was deleted.

12,993 changes: 6,457 additions & 6,536 deletions dist/index.js → dist/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/main.js.map

Large diffs are not rendered by default.

19 changes: 3 additions & 16 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Options {
env: boolean;
}

function getOptions(): Options {
export function getOptions(): Options {
return {
version: core.getInput("version"),
arch: core.getInput("arch"),
Expand Down Expand Up @@ -62,7 +62,7 @@ export function getAsset(os: string, options: Options): Asset {
return { specificVersion: options.version, url: options.forceUrl };
}

const arch = options.arch ?? process.arch;
const arch = (options.arch ?? process.arch) || "x64";
console.log(`Checking known assets (os=${os}, arch=${arch}, version=${options.version})...`);

const assets = ASSETS[os]?.[arch];
Expand Down Expand Up @@ -120,7 +120,7 @@ async function install(options: Options): Promise<void> {
core.info(`Install location: ${options.directory}`);
}

async function run(options: Options): Promise<void> {
export async function run(options: Options): Promise<void> {
if (!options.directory) {
options.directory = process.platform === "win32" ? DEFAULT_WIN32_DIRECTORY : DEFAULT_NIX_DIRECTORY;
}
Expand Down Expand Up @@ -150,16 +150,3 @@ async function run(options: Options): Promise<void> {
core.exportVariable("CXX", path.join(options.directory, "bin", "clang++"));
}
}

async function main() {
try {
await run(getOptions());
} catch (error: any) {
console.error(error.stack);
core.setFailed(error.message);
}
}

if (require.main === module) {
main();
}
15 changes: 15 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as core from "@actions/core";

import { getOptions, run } from "./index";

async function main() {
try {
await run(getOptions());
} catch (error: any) {
console.error(error.stack);
core.setFailed(error.message);
}
}

console.log("hello");
main();
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"description": "A GitHub Action for downloading and installing LLVM and Clang binaries.",
"author": "Kyle Mayes <kyle@mayeses.com>",
"license": "Apache-2.0",
"main": "dist/index.js",
"main": "dist/main.js",
"scripts": {
"format": "prettier --write *.ts",
"generate": "ts-node generate.ts",
"build": "parcel build index.ts",
"build": "parcel build main.ts",
"test": "ts-node test.ts test"
},
"dependencies": {
Expand Down

0 comments on commit 4d97c22

Please sign in to comment.