Skip to content

Commit

Permalink
test husky
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhizor committed Dec 22, 2022
1 parent 8fb6425 commit cd506cd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
12 changes: 0 additions & 12 deletions .husky/pre-commit

This file was deleted.

5 changes: 5 additions & 0 deletions action/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd action
npx lint-staged
5 changes: 5 additions & 0 deletions cli/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd cli
npx lint-staged
30 changes: 13 additions & 17 deletions cli/src/helpers/local/configFileGlobal.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import chalk from 'chalk';
import fs, {FSWatcher, readFileSync, WatchEventType} from 'fs';
import fs, { FSWatcher, readFileSync, WatchEventType } from 'fs';
import { getTypedStoatConfig, readStoatConfig } from '../../../../action/src/configHelpers';
import { StoatConfigSchema } from '../../../../action/src/schemas/stoatConfigSchema';
import {
getRemoteDefaultTemplate,
getTemplateFormat
} from '../../../../action/src/templateHelpers';
import { getRemoteDefaultTemplate, getTemplateFormat } from '../../../../action/src/templateHelpers';
import { Template } from '../../../../action/src/types';

import {findGitRoot, findStoatConfigPath} from '../pathHelpers';
import path from "path";
import { findGitRoot, findStoatConfigPath } from '../pathHelpers';
import path from 'path';

// supports reading the local template from a subdirectory
const getLocalTemplate = (commentTemplatePath: string): Template => {
Expand All @@ -21,11 +18,7 @@ const getLocalTemplate = (commentTemplatePath: string): Template => {
};

// supports reading the local template from a subdirectory if necessary
const getTemplate = async (
ghOwner: string,
ghRepo: string,
stoatConfig: StoatConfigSchema
): Promise<Template> => {
const getTemplate = async (ghOwner: string, ghRepo: string, stoatConfig: StoatConfigSchema): Promise<Template> => {
const { comment_template_file } = stoatConfig;
if (comment_template_file === undefined || comment_template_file === '') {
return getRemoteDefaultTemplate(ghOwner, ghRepo, stoatConfig);
Expand All @@ -38,16 +31,19 @@ interface TemplateWatcher {
fileWatcher: FSWatcher | undefined;
}

const getTemplateWatcher = async (oldTemplateWatcher: TemplateWatcher, commentTemplateFile: string): Promise<TemplateWatcher> => {
if(oldTemplateWatcher !== undefined) {
if(oldTemplateWatcher.commentTemplateFile === commentTemplateFile) {
const getTemplateWatcher = async (
oldTemplateWatcher: TemplateWatcher,
commentTemplateFile: string
): Promise<TemplateWatcher> => {
if (oldTemplateWatcher !== undefined) {
if (oldTemplateWatcher.commentTemplateFile === commentTemplateFile) {
return oldTemplateWatcher;
} else {
oldTemplateWatcher.fileWatcher?.close();
}
}

if(commentTemplateFile === undefined || commentTemplateFile === '') {
if (commentTemplateFile === undefined || commentTemplateFile === '') {
return {
commentTemplateFile: commentTemplateFile,
fileWatcher: undefined
Expand Down Expand Up @@ -86,7 +82,7 @@ export default class ConfigFileGlobal {
}

static getSchema() {
return this.schema;
return this.schema;
}

static getTemplate() {
Expand Down

0 comments on commit cd506cd

Please sign in to comment.