From 07b16be676e08655e0842883b12519cb782514b6 Mon Sep 17 00:00:00 2001 From: greatsquare0 Date: Mon, 4 Nov 2024 21:12:27 -0300 Subject: [PATCH] Small fix --- __tests__/download_tweego.test.ts | 3 ++- __tests__/run_tweego.test.ts | 16 +++++----------- src/run_tweego.ts | 12 +++--------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/__tests__/download_tweego.test.ts b/__tests__/download_tweego.test.ts index e3c7266..2091bc9 100644 --- a/__tests__/download_tweego.test.ts +++ b/__tests__/download_tweego.test.ts @@ -22,6 +22,7 @@ import { getTweegoUrl } from '../src/get_tweego_url' import { defaultConfig } from '../src/handle_config' import { viChdir } from './util/helpers' import { nanoid } from 'nanoid' +import { removeSync } from 'fs-extra' const getTweegoBinariePath = () => resolve( @@ -80,7 +81,7 @@ describe('Tweego download and setup', () => { await downloadTweego() await extractTweego() - rmSync(path, { recursive: true, force: true }) + removeSync(path) await downloadCustomStoryFormats() }) diff --git a/__tests__/run_tweego.test.ts b/__tests__/run_tweego.test.ts index 982f6d3..2a7636e 100644 --- a/__tests__/run_tweego.test.ts +++ b/__tests__/run_tweego.test.ts @@ -12,16 +12,13 @@ import { setupTweego } from '../src/download_tweego' import { nanoid } from 'nanoid' import { viChdir } from './util/helpers' import { verifyBinarie } from '../src/verify_tweego' -import { existsSync, outputFile, rmSync } from 'fs-extra' +import { existsSync, outputFile, removeSync } from 'fs-extra' import { resolve } from 'node:path' import { Tweenode } from '../src/run_tweego' describe('Run Tweego', () => { beforeAll(() => { - rmSync(resolve(process.cwd(), '__tests__/temp/run/'), { - recursive: true, - force: true, - }) + removeSync(resolve(process.cwd(), '__tests__/temp/run/')) }) beforeEach(() => { @@ -33,10 +30,7 @@ describe('Run Tweego', () => { }) afterAll(() => { - rmSync(resolve(process.cwd(), '__tests__/temp/util'), { - recursive: true, - force: true, - }) + removeSync(resolve(process.cwd(), '__tests__/temp/util')) }) describe('Verify Tweego Installation', () => { @@ -46,7 +40,7 @@ describe('Run Tweego', () => { }) afterEach(() => { - rmSync(process.cwd(), { recursive: true, force: true }) + removeSync(process.cwd()) }) it('should correctly setup and run', { repeats: 3 }, async () => { @@ -85,7 +79,7 @@ describe('Run Tweego', () => { }) afterAll(() => { - rmSync(path, { recursive: true, force: true }) + removeSync(path) }) it('should compile the story and return the code as a string', async () => { diff --git a/src/run_tweego.ts b/src/run_tweego.ts index 69597b6..a278319 100644 --- a/src/run_tweego.ts +++ b/src/run_tweego.ts @@ -2,11 +2,7 @@ import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process' import { resolve } from 'node:path' import { appendFileSync } from 'node:fs' import { outputFile, removeSync } from 'fs-extra/esm' -import type { - TweenodeBuildConfig, - TweenodeDebugConfig, - TweenodeSetupConfig, -} from './handle_config' +import type { TweenodeBuildConfig, TweenodeDebugConfig } from './handle_config' import { config as loadedConfig } from './state' @@ -14,7 +10,6 @@ import { verifyBinarie } from './verify_tweego' import { getTweenodeFolderPath } from './download_tweego' export class Tweenode { - setupConfig: TweenodeSetupConfig buildConfig: TweenodeBuildConfig debugConfig: TweenodeDebugConfig childProcess: ChildProcessWithoutNullStreams | undefined @@ -22,10 +17,9 @@ export class Tweenode { private stdio: undefined | ProcessStdioReturn tweegoBinariePath: string - constructor(setupOptions?: TweenodeSetupConfig) { - this.setupConfig = { ...loadedConfig.setup, ...setupOptions } + constructor(debugOptions?: TweenodeDebugConfig) { this.buildConfig = { ...loadedConfig.build! } - this.debugConfig = { ...loadedConfig.debug! } + this.debugConfig = { ...loadedConfig.debug!, ...debugOptions } this.childProcess = undefined this.isRunning = false this.stdio = undefined