-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.test-d.ts
38 lines (35 loc) · 1.79 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import process from 'node:process';
import {expectType, expectError} from 'tsd';
import {npmRunPath, npmRunPathEnv, type ProcessEnv} from './index.js';
const fileUrl = new URL('file:///foo');
expectType<string>(npmRunPath());
expectType<string>(npmRunPath({cwd: '/foo'}));
expectType<string>(npmRunPath({cwd: fileUrl}));
expectError(npmRunPath({cwd: false}));
expectType<string>(npmRunPath({path: '/usr/local/bin'}));
expectError(npmRunPath({path: fileUrl}));
expectError(npmRunPath({path: false}));
expectType<string>(npmRunPath({execPath: '/usr/local/bin'}));
expectType<string>(npmRunPath({execPath: fileUrl}));
expectError(npmRunPath({execPath: false}));
expectType<string>(npmRunPath({addExecPath: false}));
expectError(npmRunPath({addExecPath: ''}));
expectType<string>(npmRunPath({preferLocal: false}));
expectError(npmRunPath({preferLocal: ''}));
expectType<ProcessEnv>(npmRunPathEnv());
expectType<ProcessEnv>(npmRunPathEnv({cwd: '/foo'}));
expectType<ProcessEnv>(npmRunPathEnv({cwd: fileUrl}));
expectError(npmRunPathEnv({cwd: false}));
expectType<ProcessEnv>(npmRunPathEnv({env: process.env})); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
expectType<ProcessEnv>(npmRunPathEnv({env: {foo: 'bar'}}));
expectType<ProcessEnv>(npmRunPathEnv({env: {foo: undefined}}));
expectError(npmRunPath({env: false}));
expectError(npmRunPath({env: {[Symbol('key')]: 'bar'}}));
expectError(npmRunPath({env: {foo: false}}));
expectType<ProcessEnv>(npmRunPathEnv({execPath: '/usr/local/bin'}));
expectType<ProcessEnv>(npmRunPathEnv({execPath: fileUrl}));
expectError(npmRunPath({execPath: false}));
expectType<ProcessEnv>(npmRunPathEnv({addExecPath: false}));
expectError(npmRunPathEnv({addExecPath: ''}));
expectType<ProcessEnv>(npmRunPathEnv({preferLocal: false}));
expectError(npmRunPathEnv({preferLocal: ''}));