Skip to content

Commit b85d4a3

Browse files
committed
add: some documentation
1 parent 14adf64 commit b85d4a3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# LLS-Addons-Action
2+
A custom GitHub action that is used by [LLS-Addons](https://github.com/carsakiller/LLS-Addons) to get some metadata on addons such as their size and if they contain a plugin.
3+
4+
This is ***very*** niche so there is probably no other use case than when being used by [LLS-Addons](https://github.com/carsakiller/LLS-Addons).
5+
6+
## How it works
7+
It expects that the repo has been [checked out](https://github.com/actions/checkout), **including its submodules**. It will then get a list of all submodules, get their metadata, and then write it to their `info.json` file. This allows the addon manager of [vscode-lua](https://github.com/sumneko/vscode-lua) to have metadata on the addon without pulling the whole submodule first.

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import * as fs from "fs";
55

66
const submoduleRegex = /([A-z0-9]+) (.*\/.*) .*/g;
77

8+
/** Calculate the size of a directory, recursively
9+
* @param directory The path to the directory
10+
* @return The size of the directory in bytes
11+
*/
812
async function getDirectorySize(directory: string): Promise<number> {
913
let totalSize = 0;
1014

@@ -38,7 +42,9 @@ async function run() {
3842
const info = JSON.parse(rawInfo.toString());
3943

4044
info.size = await getDirectorySize(submodulePath);
41-
info.hasPlugin = fs.existsSync(path.join(submodulePath, "module", "plugin.lua"));
45+
info.hasPlugin = fs.existsSync(
46+
path.join(submodulePath, "module", "plugin.lua")
47+
);
4248

4349
fs.promises.writeFile(infoFilePath, JSON.stringify(info, null, " "));
4450
}

0 commit comments

Comments
 (0)