From bae293ca7001633b8e1d078802b226f1af0b3d97 Mon Sep 17 00:00:00 2001 From: greatsquare0 Date: Mon, 21 Oct 2024 23:59:38 -0300 Subject: [PATCH] Fix two critical bug, updated ci workflow --- .github/workflows/ci.yml | 6 ------ __tests__/download_tweego.test.ts | 5 ++--- __tests__/run_tweego.test.ts | 4 ++-- package.json | 2 +- src/handle_config.ts | 23 ++++++++++++----------- src/run_tweego.ts | 4 ++++ vitest.config.ts | 2 ++ 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03a540a..7503daa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,12 +23,6 @@ jobs: name: Checkout uses: actions/checkout@v3 - - id: setup-bun - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - id: setup-pnpm name: Setup pnpm uses: pnpm/action-setup@v4 diff --git a/__tests__/download_tweego.test.ts b/__tests__/download_tweego.test.ts index 3fe770e..e3c7266 100644 --- a/__tests__/download_tweego.test.ts +++ b/__tests__/download_tweego.test.ts @@ -61,7 +61,7 @@ describe('Tweego download and setup', () => { expect(content[0]).toEqual(archiveName) }) - it('Should correctly unzip the archive', { timeout: 32000 }, async () => { + it('Should correctly unzip the archive', async () => { await downloadTweego() await extractTweego() expect(existsSync(getTweegoBinariePath())).toEqual(true) @@ -69,7 +69,6 @@ describe('Tweego download and setup', () => { describe.todo( 'Should correctly download specified storyformats', - { timeout: 99999 }, async () => { let path = '' @@ -83,7 +82,7 @@ describe('Tweego download and setup', () => { rmSync(path, { recursive: true, force: true }) await downloadCustomStoryFormats() - }, 99999) + }) const cases = defaultConfig.setup!.storyFormats!.formats! diff --git a/__tests__/run_tweego.test.ts b/__tests__/run_tweego.test.ts index 6884466..d945200 100644 --- a/__tests__/run_tweego.test.ts +++ b/__tests__/run_tweego.test.ts @@ -43,7 +43,7 @@ describe('Run Tweego', () => { beforeEach(async () => { viChdir(resolve(process.cwd(), `${nanoid(6)}/`)) await setupTweego() - }, 32000) + }) afterEach(() => { rmSync(process.cwd(), { recursive: true, force: true }) @@ -82,7 +82,7 @@ describe('Run Tweego', () => { } ) } - }, 999999) + }) afterAll(() => { rmSync(path, { recursive: true, force: true }) diff --git a/package.json b/package.json index 72d8c2a..4b920f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tweenode", - "version": "0.2.2", + "version": "0.2.3", "description": "A neat JS wrapper for Tweego", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/handle_config.ts b/src/handle_config.ts index 8ff5d35..c72b823 100644 --- a/src/handle_config.ts +++ b/src/handle_config.ts @@ -67,8 +67,9 @@ export const loadConfig = async ( return defaultConfig as TweenodeConfig } - const config = await import(configPath) + const imported = await import(configPath) + const config = imported.default cache = config return config } @@ -76,15 +77,15 @@ export const loadConfig = async ( export const defaultConfig: Partial = { build: { output: { - mode: 'string' + mode: 'string', }, input: { - storyDir: '' - } + storyDir: '', + }, }, setup: { tweegoBinaries: { - version: '2.1.1' + version: '2.1.1', }, storyFormats: { useTweegoBuiltin: false, @@ -94,17 +95,17 @@ export const defaultConfig: Partial = { version: '2.37.0', local: false, src: 'https://github.com/tmedwards/sugarcube-2/releases/download/v2.37.0/sugarcube-2.37.0-for-twine-2.1-local.zip', - createFolder: false + createFolder: false, }, { name: 'harlowe4-unstable', version: '4.0.0', src: 'https://twine2.neocities.org/harlowe4-unstable.js', - createFolder: true - } - ] - } - } + createFolder: true, + }, + ], + }, + }, } /** diff --git a/src/run_tweego.ts b/src/run_tweego.ts index fa8c247..f51dbc1 100644 --- a/src/run_tweego.ts +++ b/src/run_tweego.ts @@ -44,6 +44,10 @@ export class Tweenode { try { this.childProcess = spawn(this.tweegoBinariePath, args, { detached: true, + env: { + ...process.env, + TWEEGO_PATH: resolve(getTweenodeFolderPath(), 'storyformats'), + }, }) this.isRunning = true } catch (error) { diff --git a/vitest.config.ts b/vitest.config.ts index 2c6cdb3..87bd2a5 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,5 +3,7 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { setupFiles: ['./__tests__/vitest.setup.ts'], + testTimeout: process.platform == 'win32' ? 50000 : 10000, + hookTimeout: process.platform == 'win32' ? 50000 : 10000, }, })