built-artifacts.e2e.ts 1.2 KB

12345678910111213141516171819202122232425262728
  1. import { execFile } from 'node:child_process'
  2. import { existsSync } from 'node:fs'
  3. import { join } from 'node:path'
  4. import { fileURLToPath } from 'node:url'
  5. import { promisify } from 'node:util'
  6. import { describe, expect, it } from 'vitest'
  7. const execFileAsync = promisify(execFile)
  8. const repoRoot = fileURLToPath(new URL('../../../../', import.meta.url))
  9. const createBin = join(repoRoot, 'packages/sdk/create-sdk/lib/bin.js')
  10. const scriptsBin = join(repoRoot, 'packages/sdk/scripts/lib/bin.js')
  11. describe.skipIf(!existsSync(createBin) || !existsSync(scriptsBin))(
  12. 'SDK built artifacts',
  13. () => {
  14. it('runs the published dsh-sdk bin help path under plain Node', async () => {
  15. const result = await execFileAsync(process.execPath, [scriptsBin, '--help'], { encoding: 'utf8' })
  16. expect(result.stdout).toContain('Usage: dsh-sdk <command>')
  17. expect(result.stderr).toBe('')
  18. })
  19. it('runs the published create-sdk bin help path under plain Node', async () => {
  20. const result = await execFileAsync(process.execPath, [createBin, '--help'], { encoding: 'utf8' })
  21. expect(result.stdout).toContain('Usage: create-sdk [directory]')
  22. expect(result.stderr).toBe('')
  23. })
  24. },
  25. )