diff --git a/.eslintrc.js b/.eslintrc.js index b300023..526ef78 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,6 +21,11 @@ module.exports = { 'no-use-before-define': ['error', { functions: false }], '@typescript-eslint/no-use-before-define': ['error', { functions: false }], 'import/prefer-default-export': 'off', + 'lines-between-class-members': [ + 'error', + 'always', + { exceptAfterSingleLine: true }, + ], 'import/extensions': [ 'error', 'always', diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a0d1be4..0c5d0fd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,8 @@ jobs: run: yarn lint - run: yarn build name: Compile Typescript + - run: yarn test + name: Run tests - name: Publish uses: mikeal/merge-release@master env: diff --git a/package.json b/package.json index be7d810..df58ff6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wetty", - "version": "1.2.2", + "version": "1.2.3", "description": "WeTTY = Web + TTY. Terminal access in browser over http/https", "homepage": "https://github.com/butlerx/wetty", "repository": { diff --git a/src/client/download.ts b/src/client/download.ts index cf15e59..7db2064 100644 --- a/src/client/download.ts +++ b/src/client/download.ts @@ -2,8 +2,14 @@ const DEFAULT_FILE_BEGIN = '\u001b[5i'; const DEFAULT_FILE_END = '\u001b[4i'; export class FileDownloader { + fileBuffer: string[]; + fileBegin: string; + fileEnd: string; + partialFileBegin: string; + onCompleteFileCallback: Function; + constructor( - onCompleteFileCallback: (file: string) => any, + onCompleteFileCallback: (file: string) => void, fileBegin: string = DEFAULT_FILE_BEGIN, fileEnd: string = DEFAULT_FILE_END ) { @@ -87,10 +93,13 @@ export class FileDownloader { ) { return data; } - return data.split('').map(this.bufferCharacter.bind(this)).join('') + return data + .split('') + .map(this.bufferCharacter.bind(this)) + .join(''); } - onCompleteFile(bufferCharacters: string) { + onCompleteFile(bufferCharacters: string): void { this.onCompleteFileCallback(bufferCharacters); } } diff --git a/src/client/index.ts b/src/client/index.ts index eee0940..454f038 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -1,8 +1,8 @@ import { Terminal } from 'xterm'; import { isNull } from 'lodash'; -import { dom, library } from "@fortawesome/fontawesome-svg-core"; -import { faCogs } from "@fortawesome/free-solid-svg-icons/faCogs"; +import { dom, library } from '@fortawesome/fontawesome-svg-core'; +import { faCogs } from '@fortawesome/free-solid-svg-icons/faCogs'; import Toastify from 'toastify-js'; import * as fileType from 'file-type'; import { socket } from './socket'; @@ -78,9 +78,7 @@ socket.on('connect', () => { term.focus(); mobileKeyboard(); - const fileDownloader = new FileDownloader(function ( - bufferCharacters: string - ) { + const fileDownloader = new FileDownloader((bufferCharacters: string) => { let fileCharacters = bufferCharacters; // Try to decode it as base64, if it fails we assume it's not base64 try {