Skip to content

Commit 4d97c22

Browse files
committed
Move main into separate file
1 parent 672fbb5 commit 4d97c22

File tree

7 files changed

+6479
-6556
lines changed

7 files changed

+6479
-6556
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ outputs:
3737

3838
runs:
3939
using: "node20"
40-
main: "dist/index.js"
40+
main: "dist/main.js"

dist/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/index.js renamed to dist/main.js

Lines changed: 6457 additions & 6536 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Options {
1818
env: boolean;
1919
}
2020

21-
function getOptions(): Options {
21+
export function getOptions(): Options {
2222
return {
2323
version: core.getInput("version"),
2424
arch: core.getInput("arch"),
@@ -62,7 +62,7 @@ export function getAsset(os: string, options: Options): Asset {
6262
return { specificVersion: options.version, url: options.forceUrl };
6363
}
6464

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

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

123-
async function run(options: Options): Promise<void> {
123+
export async function run(options: Options): Promise<void> {
124124
if (!options.directory) {
125125
options.directory = process.platform === "win32" ? DEFAULT_WIN32_DIRECTORY : DEFAULT_NIX_DIRECTORY;
126126
}
@@ -150,16 +150,3 @@ async function run(options: Options): Promise<void> {
150150
core.exportVariable("CXX", path.join(options.directory, "bin", "clang++"));
151151
}
152152
}
153-
154-
async function main() {
155-
try {
156-
await run(getOptions());
157-
} catch (error: any) {
158-
console.error(error.stack);
159-
core.setFailed(error.message);
160-
}
161-
}
162-
163-
if (require.main === module) {
164-
main();
165-
}

main.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as core from "@actions/core";
2+
3+
import { getOptions, run } from "./index";
4+
5+
async function main() {
6+
try {
7+
await run(getOptions());
8+
} catch (error: any) {
9+
console.error(error.stack);
10+
core.setFailed(error.message);
11+
}
12+
}
13+
14+
console.log("hello");
15+
main();

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "A GitHub Action for downloading and installing LLVM and Clang binaries.",
55
"author": "Kyle Mayes <[email protected]>",
66
"license": "Apache-2.0",
7-
"main": "dist/index.js",
7+
"main": "dist/main.js",
88
"scripts": {
99
"format": "prettier --write *.ts",
1010
"generate": "ts-node generate.ts",
11-
"build": "parcel build index.ts",
11+
"build": "parcel build main.ts",
1212
"test": "ts-node test.ts test"
1313
},
1414
"dependencies": {

0 commit comments

Comments
 (0)