Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
feat(action): optional files (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
fersilva16 authored Aug 10, 2022
1 parent 531bf33 commit 7871f92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ branding:
inputs:
project:
description: 'TypeScript project file'
required: false
files:
description: 'Files to check'
required: false
21 changes: 17 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { error, getInput, setFailed } from '@actions/core';
import ts from 'typescript';
import path from 'path';

const check = async (projectPath: string, files: string[]) => {
const check = async (projectPath: string, files?: string[]) => {
const json = ts.readConfigFile(projectPath, ts.sys.readFile);

if (json.error) {
Expand All @@ -11,15 +11,28 @@ const check = async (projectPath: string, files: string[]) => {
return;
}

const getFilesOptions = () => {
if (!files) return {};

return {
compilerOptions: {
skipLibCheck: true,
},
files,
include: [],
};
};

const filesOptions = getFilesOptions();

const config = ts.parseJsonConfigFileContent(
{
...json.config,
...filesOptions,
compilerOptions: {
...json.config.compilerOptions,
skipLibCheck: true,
...filesOptions.compilerOptions,
},
files,
include: [],
},
ts.sys,
path.dirname(projectPath),
Expand Down

0 comments on commit 7871f92

Please sign in to comment.