Skip to content

Commit

Permalink
fix: do not emit process title to stdout (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltvolks authored Apr 4, 2023
1 parent acdcf84 commit de05e99
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { PackageJson } from '.';
import { Config, defaultConfig } from './lib/config';
import { closeBrowser } from './lib/generate-output';
import { help } from './lib/help';
import { setProcessAndTermTitle } from './lib/helpers';
import { convertMdToPdf } from './lib/md-to-pdf';
import { closeServer, serveDirectory } from './lib/serve-dir';
import { validateNodeVersion } from './lib/validate-node-version';
Expand Down Expand Up @@ -64,7 +63,7 @@ main(cliFlags, defaultConfig).catch((error) => {
// Define Main Function

async function main(args: typeof cliFlags, config: Config) {
setProcessAndTermTitle('md-to-pdf');
process.title = 'md-to-pdf';

if (!validateNodeVersion()) {
throw new Error('Please use a Node.js version that satisfies the version specified in the engines field.');
Expand Down
5 changes: 0 additions & 5 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,3 @@ export const getMarginObject = (margin: string): PDFOptions['margin'] => {
? { top, right: top, bottom: top, left: top }
: undefined;
};

export const setProcessAndTermTitle = (title: string) => {
process.title = title;
process.stdout.write(`${String.fromCharCode(27)}]0;${title}${String.fromCharCode(7)}`);
};
6 changes: 1 addition & 5 deletions src/test/lib.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { defaultConfig } from '../lib/config';
import { getHtml } from '../lib/get-html';
import { getMarked } from '../lib/get-marked-with-highlighter';
import { getOutputFilePath } from '../lib/get-output-file-path';
import { getDir, getMarginObject, setProcessAndTermTitle } from '../lib/helpers';
import { getDir, getMarginObject } from '../lib/helpers';
import { isHttpUrl } from '../lib/is-http-url';
import { isMdFile } from '../lib/is-md-file';
import { readFile } from '../lib/read-file';
Expand All @@ -22,10 +22,6 @@ test("gray-matter's js engine is disabled by default", (t) => {
// --
// helpers

test('setProcessAndTermTitle should not throw', (t) => {
t.notThrows(() => setProcessAndTermTitle('md-to-pdf tests'));
});

test('getDir should get the directory the given file is in', (t) => {
const filePath = posix.join('/', 'var', 'foo', 'bar.txt');

Expand Down

0 comments on commit de05e99

Please sign in to comment.