Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
greatsquare0 committed Nov 5, 2024
1 parent 7e75f85 commit 07b16be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
3 changes: 2 additions & 1 deletion __tests__/download_tweego.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -80,7 +81,7 @@ describe('Tweego download and setup', () => {
await downloadTweego()
await extractTweego()

rmSync(path, { recursive: true, force: true })
removeSync(path)
await downloadCustomStoryFormats()
})

Expand Down
16 changes: 5 additions & 11 deletions __tests__/run_tweego.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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', () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
12 changes: 3 additions & 9 deletions src/run_tweego.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,24 @@ 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'

import { verifyBinarie } from './verify_tweego'
import { getTweenodeFolderPath } from './download_tweego'

export class Tweenode {
setupConfig: TweenodeSetupConfig
buildConfig: TweenodeBuildConfig
debugConfig: TweenodeDebugConfig
childProcess: ChildProcessWithoutNullStreams | undefined
isRunning: boolean
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
Expand Down

0 comments on commit 07b16be

Please sign in to comment.