Skip to content

Commit b7585f0

Browse files
committed
Rename and rework library input
1 parent dc8acc9 commit b7585f0

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

.github/workflows/run-self.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run the action
3333
uses: ./
3434
with:
35-
library-path: roc-json/Json
35+
library: roc-json/Json/main.roc
3636
token: ${{ secrets.GITHUB_TOKEN }}
3737
- name: Make sure Roc is installed
3838
run: roc --version

action.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ name: Bundle a Roc library
22
description: Bundle and release a Roc library.
33

44
inputs:
5-
library-path:
6-
description: The path to the library's folder containing a `main.roc` file.
5+
library:
6+
description: The path to the library's entrypoint file.
77
required: true
8-
default: .
98
roc-path:
109
description: The absolute path to Roc. If this variable is not specified the action will try to find Roc using the `PATH` environment variable.
1110
required: true

dist/index.js

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

src/index.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,40 @@ type BundleType = ".tar" | ".tar.gz" | ".tar.br";
99

1010
const bundleLibrary = (
1111
rocPath: string,
12-
libraryPath: string,
12+
libraryEntrypointPath: string,
1313
bundleType: BundleType
1414
) => {
1515
const bundleCommand = [
1616
rocPath,
1717
"build",
1818
"--bundle",
1919
bundleType,
20-
path.join(libraryPath, "main.roc"),
20+
libraryEntrypointPath,
2121
]
22-
.map((x) => (x.includes(" ") ? `"${x}"` : x))
22+
.map((x) => (x.includes(" ") ? `"${x}"` : x)) // Add quotes to paths that contain spaces
2323
.join(" ");
2424
core.info(`Running bundle command '${bundleCommand}'.`);
2525
const stdOut = execSync(bundleCommand);
2626
core.info(stdOut.toString());
2727
};
2828

2929
const getBundlePath = async (
30-
libraryPath: string,
30+
libraryEntrypointPath: string,
3131
bundleType: BundleType
3232
): Promise<string> => {
33+
const libraryFolder = path.dirname(libraryEntrypointPath);
3334
core.info(
34-
`Looking for bundled library in '${libraryPath}' with extension '${bundleType}'.`
35+
`Looking for bundled library in '${libraryFolder}' with extension '${bundleType}'.`
3536
);
3637
const bundleFileName = fs
37-
.readdirSync(libraryPath)
38+
.readdirSync(libraryFolder)
3839
.find((x) => x.endsWith(bundleType));
3940
if (bundleFileName === undefined) {
4041
throw new Error(
41-
`Couldn't find bundled library in '${libraryPath}' with extension '${bundleType}'.`
42+
`Couldn't find bundled library in '${libraryFolder}' with extension '${bundleType}'.`
4243
);
4344
}
44-
const bundlePath = path.resolve(path.join(libraryPath, bundleFileName));
45+
const bundlePath = path.resolve(path.join(libraryFolder, bundleFileName));
4546
core.info(`Found bundled library at '${bundlePath}'.`);
4647
return bundlePath;
4748
};
@@ -93,7 +94,7 @@ const main = async () => {
9394
const isRequired = { required: true };
9495
const token = core.getInput("token");
9596
const bundleType = core.getInput("bundle-type", isRequired) as BundleType;
96-
const libraryPath = core.getInput("library-path", isRequired);
97+
const libraryEntrypointPath = core.getInput("library", isRequired);
9798
const release = core.getBooleanInput("release", isRequired);
9899
const releaseTag = core
99100
.getInput("tag", { required: release })
@@ -102,8 +103,8 @@ const main = async () => {
102103
const octokitClient = gh.getOctokit(token);
103104

104105
// Bundle the library
105-
bundleLibrary(rocPath, libraryPath, bundleType);
106-
const bundlePath = await getBundlePath(libraryPath, bundleType);
106+
bundleLibrary(rocPath, libraryEntrypointPath, bundleType);
107+
const bundlePath = await getBundlePath(libraryEntrypointPath, bundleType);
107108
core.setOutput("bundle-path", bundlePath);
108109

109110
// Publish the bundle

0 commit comments

Comments
 (0)