Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejlv committed Nov 5, 2024
1 parent 817dac1 commit 484c9b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
7 changes: 2 additions & 5 deletions action.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[hello]
cmd = "echo 'Hello, world!'"

[build]
cmd = "bun -v"
[dev]
cmd = "bunx concurrently -k -n test1,test2 -c magenta,blue \"echo 'Test 1 Works'\" \"echo 'Test 2 Works'\""
Binary file modified bun.lockb
Binary file not shown.
28 changes: 8 additions & 20 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,24 @@ import child_process from 'child_process';

const CONFIG_FILE = 'action.toml';

if (!fs.existsSync(CONFIG_FILE)) {
console.error(`failed to find config file: ${CONFIG_FILE}`);
process.exit(1);
}

const commandSchema = z.object({
cmd: z.string().min(1),
});

const cliCommands = ['list', 'version', 'help']
const cliCommands = ['list', 'version', 'help'];

let cmd;

try {
const commands = await import(`${process.cwd()}/${CONFIG_FILE}`);
const commandToRun = process.argv[2];


if (commandToRun && cliCommands.includes(commandToRun)) {


switch (commandToRun) {
case 'list':
console.log('Available commands:');
Object.keys(commands.default).forEach((command) => {
console.log(
` ${command}`
)

console.log(` ${command}`);
});
break;
case 'version':
Expand All @@ -44,18 +33,17 @@ try {
console.log('Usage: action <command>');
console.log('Available commands:');
cliCommands.forEach((command) => {
console.log(
` ${command}`
)

}
);
console.log(` ${command}`);
});
}

process.exit(0);
}


if (!fs.existsSync(CONFIG_FILE)) {
console.error(`failed to find config file: ${CONFIG_FILE}`);
process.exit(1);
}

if (!commandToRun) {
// Access the first command from the default export
Expand Down

0 comments on commit 484c9b5

Please sign in to comment.