1+ import { mkdtempSync , rmSync , symlinkSync } from 'node:fs'
2+ import path from 'node:path'
3+ import { tmpdir } from 'node:os'
4+ import { fileURLToPath } from 'node:url'
15import { afterEach , describe , expect , it , vi } from 'vitest'
2- import { main , runSmartSig } from '../../src/cli.ts'
6+ import { main , runSmartSig , shouldRunCli } from '../../src/cli.ts'
37import { Transloadit } from '../../src/Transloadit.ts'
48
59const mockedExpiresDate = '2025-01-01T00:00:00.000Z'
@@ -19,6 +23,20 @@ afterEach(() => {
1923} )
2024
2125describe ( 'cli smart_sig' , ( ) => {
26+ it ( 'recognizes symlinked invocation paths' , ( ) => {
27+ const tmpDir = mkdtempSync ( path . join ( tmpdir ( ) , 'transloadit-cli-' ) )
28+ const symlinkTarget = fileURLToPath ( new URL ( '../../src/cli.ts' , import . meta. url ) )
29+ const symlinkPath = path . join ( tmpDir , 'transloadit' )
30+
31+ symlinkSync ( symlinkTarget , symlinkPath )
32+ try {
33+ expect ( shouldRunCli ( symlinkPath ) ) . toBe ( true )
34+ } finally {
35+ rmSync ( symlinkPath )
36+ rmSync ( tmpDir , { recursive : true , force : true } )
37+ }
38+ } )
39+
2240 it ( 'overwrites auth key with env credentials' , async ( ) => {
2341 mockExpires ( )
2442 vi . stubEnv ( 'TRANSLOADIT_KEY' , 'key' )
0 commit comments