Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
fix: move ts-node register inside ts if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
arantespp committed Oct 18, 2020
1 parent 0f1cd89 commit 4d6607b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/cli/src/utils/readObjectFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
import fs from 'fs';
import yaml from 'js-yaml';

require('ts-node').register({
compilerOptions: { module: 'commonjs' },
transpileOnly: true,
});

export const readYaml = ({ path }: { path: string }) => {
const template = fs.readFileSync(path, 'utf8') || JSON.stringify({});
return yaml.safeLoad(template);
Expand All @@ -22,6 +17,10 @@ export const readObjectFile = ({ path }: { path: string }) => {
const extension = path.split('.').pop();

if (extension === 'ts') {
require('ts-node').register({
compilerOptions: { module: 'commonjs' },
transpileOnly: true,
});
const tsObj = require(path);
const obj = tsObj.default || tsObj;
return typeof obj === 'function' ? obj() : obj;
Expand Down

0 comments on commit 4d6607b

Please sign in to comment.