Skip to content

Commit

Permalink
chore: Update pre-commit script to check if running in a terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed May 24, 2024
1 parent ee1cf30 commit 944899d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
exec >/dev/tty 2>&1

# Check if running in a terminal
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
# Unix-like OS detected, proceed with redirection
exec >/dev/tty 2>&1
fi

# Continue with the rest of the script
yarn lint-staged
10 changes: 10 additions & 0 deletions packages/sn-editor-react/test/image-control.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import { defaultLocalization } from '../src/context'
import { createExtensions } from '../src/extension-list'
import { FileReaderMock } from './__mocks__/file-reader'

jest.mock('react-monaco-editor', () =>
jest.fn((props) => {
console.log(props)
return (
<div data-test="mock-monaco-editor" onChange={props.fieldOnChange} ref={props.editorRef}>
{props.value}
</div>
)
}),
)
describe('image control', () => {
const onChange = jest.fn(({ editor }) => editor.getHTML())
const editor = new TiptapEditor({
Expand Down
11 changes: 11 additions & 0 deletions packages/sn-editor-react/test/link-control.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import { LinkControl } from '../src/components/controls'
import { defaultLocalization } from '../src/context'
import { createExtensions } from '../src/extension-list'

jest.mock('react-monaco-editor', () =>
jest.fn((props) => {
console.log(props)
return (
<div data-test="mock-monaco-editor" onChange={props.fieldOnChange} ref={props.editorRef}>
{props.value}
</div>
)
}),
)

describe('link control', () => {
const onChange = jest.fn(({ editor }) => editor.getHTML())
const editor = new TiptapEditor({
Expand Down
11 changes: 11 additions & 0 deletions packages/sn-editor-react/test/table-control.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import { TableControl } from '../src/components/controls'
import { defaultLocalization } from '../src/context'
import { createExtensions } from '../src/extension-list'

jest.mock('react-monaco-editor', () =>
jest.fn((props) => {
console.log(props)
return (
<div data-test="mock-monaco-editor" onChange={props.fieldOnChange} ref={props.editorRef}>
{props.value}
</div>
)
}),
)

describe('table control', () => {
const onChange = jest.fn(({ editor }) => editor.getHTML())
const editor = new TiptapEditor({
Expand Down
11 changes: 11 additions & 0 deletions packages/sn-editor-react/test/typography-control.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ import { TypographyControl } from '../src/components/controls'
import { defaultLocalization } from '../src/context'
import { createExtensions } from '../src/extension-list'

jest.mock('react-monaco-editor', () =>
jest.fn((props) => {
console.log(props)
return (
<div data-test="mock-monaco-editor" onChange={props.fieldOnChange} ref={props.editorRef}>
{props.value}
</div>
)
}),
)

describe('typography control', () => {
const editor = new TiptapEditor({
content: '<h6>Hello</h6><p>world</p>',
Expand Down

0 comments on commit 944899d

Please sign in to comment.