Skip to content

Commit

Permalink
add ability to require files from CLI
Browse files Browse the repository at this point in the history
related to #341
  • Loading branch information
jbielick committed Aug 31, 2022
1 parent 3d26cd0 commit 54835fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ jspm_packages
lib

issues

hack
13 changes: 12 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

import { Command } from "commander";
import path from "path";
const program = new Command();

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand All @@ -26,6 +27,16 @@ function collectQueues(val: string, memo: QueuesFromArgs): QueuesFromArgs {
return memo;
}

function requirePath(val: string) {
if (path.isAbsolute(val)) {
require(val);
} else if (val.startsWith(".")) {
require(path.resolve(val));
} else {
require(val);
}
}

program
.version(`faktory-worker ${version}`)
.usage("[options]")
Expand All @@ -48,7 +59,7 @@ program
.option("-t, --timeout <n>", "shutdown timeout", parseInt)
// .option('-e, --environment <env>', 'application environment')
.option("-l, --label <label>", "worker label", collect, [])
// .option('-r, --require <path>', 'worker directory to require')
.option("-r, --require <path>", "worker directory to require", requirePath)
.option("-v, --verbose", "print verbose output")
.option("-v, --version", "print version and exit")
.parse(process.argv);
Expand Down

0 comments on commit 54835fd

Please sign in to comment.