Skip to content

Commit

Permalink
fix: move ts-node registration into build command
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Jul 6, 2022
1 parent e3f33ad commit 4876efd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/bin.ts
@@ -1,11 +1,8 @@
#!/usr/bin/env node
import * as tsNode from "ts-node";
import * as yargs from "yargs";
import { build } from "./commands/build";
import { watch } from "./commands/watch";

tsNode.register({ dir: process.cwd() });

yargs
.scriptName("github-actions-wac")
.usage("$0 <cmd> [args]")
Expand Down
14 changes: 14 additions & 0 deletions src/commands/build.ts
Expand Up @@ -3,6 +3,7 @@ import * as path from "path";
import jsYaml from "js-yaml";
import debug from "debug";
import { getWorkflowsPaths, clearImportCache } from "./utils";
import * as tsNode from "ts-node";

const log = debug("ghawac");

Expand All @@ -15,7 +16,20 @@ const TOP_YAML_WORKFLOW_COMMENT = [
'# For more information, run "github-actions-wac --help".'
].join("\n");

let tsNodeRegistered = false;
const registerTsNode = (options = {}) => {
if (tsNodeRegistered) {
return;
}

tsNode.register({...options });
tsNodeRegistered = true;
};

export const build = async () => {

registerTsNode();

const workflowFilesPaths = getWorkflowsPaths();
log(
"Detected following workflow files:\n",
Expand Down

0 comments on commit 4876efd

Please sign in to comment.