Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scripts/_smoke-utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export function readStream(stream) {
return new Promise((resolve, reject) => {
let output = ''
stream.setEncoding('utf8')
stream.on('data', chunk => {
output += chunk
})
stream.on('error', reject)
stream.on('end', () => resolve(output))
})
}

export function waitForExit(child) {
return new Promise((resolve, reject) => {
child.on('error', reject)
child.on('exit', code => resolve(code ?? 1))
})
}
21 changes: 1 addition & 20 deletions scripts/package-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { readStream, waitForExit } from './_smoke-utils.mjs'

const packageBinName = 'konteks-cli'
const manager = process.argv[2]
Expand Down Expand Up @@ -172,23 +173,3 @@ async function run(command, args, options = { isolatedHome: true }) {
output: `${stdout}\n${stderr}`.trim(),
}
}

function readStream(stream) {
return new Promise((resolve, reject) => {
let output = ''

stream.setEncoding('utf8')
stream.on('data', chunk => {
output += chunk
})
stream.on('error', reject)
stream.on('end', () => resolve(output))
})
}

function waitForExit(child) {
return new Promise((resolve, reject) => {
child.on('error', reject)
child.on('exit', code => resolve(code ?? 1))
})
}
21 changes: 1 addition & 20 deletions scripts/runtime-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { spawn } from 'node:child_process'
import { mkdir, mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { readStream, waitForExit } from './_smoke-utils.mjs'

const runtime = process.argv[2]
const supportedRuntimes = new Set(['bun', 'node'])
Expand Down Expand Up @@ -115,23 +116,3 @@ async function runCli(args) {
await rm(homeDir, { force: true, recursive: true })
}
}

function readStream(stream) {
return new Promise((resolve, reject) => {
let output = ''

stream.setEncoding('utf8')
stream.on('data', chunk => {
output += chunk
})
stream.on('error', reject)
stream.on('end', () => resolve(output))
})
}

function waitForExit(child) {
return new Promise((resolve, reject) => {
child.on('error', reject)
child.on('exit', code => resolve(code ?? 1))
})
}
Loading