@@ -5,7 +5,7 @@ import globby from 'globby';
5
5
import { getDiagnostics as getTSDiagnostics } from './compiler' ;
6
6
import loadConfig from './config' ;
7
7
import getCustomDiagnostics from './rules' ;
8
- import { Context , Config , Diagnostic , PackageJsonWithTsdConfig } from './interfaces' ;
8
+ import { Context , Config , Diagnostic , PackageJsonWithTsdConfig , TsdError } from './interfaces' ;
9
9
10
10
export interface Options {
11
11
cwd : string ;
@@ -25,7 +25,7 @@ const findTypingsFile = async (pkg: PackageJsonWithTsdConfig, options: Options):
25
25
const typingsExist = await pathExists ( typingsPath ) ;
26
26
27
27
if ( ! typingsExist ) {
28
- throw new Error ( `The type definition \`${ typings } \` does not exist at \`${ typingsPath } \`. Is the path correct? Create one and try again.` ) ;
28
+ throw new TsdError ( `The type definition \`${ typings } \` does not exist at \`${ typingsPath } \`. Is the path correct? Create one and try again.` ) ;
29
29
}
30
30
31
31
return typings ;
@@ -43,7 +43,7 @@ const findCustomTestFiles = async (testFilesPattern: readonly string[], cwd: str
43
43
const testFiles = await globby ( testFilesPattern , { cwd} ) ;
44
44
45
45
if ( testFiles . length === 0 ) {
46
- throw new Error ( 'Could not find any test files with the given pattern(s). Create one and try again.' ) ;
46
+ throw new TsdError ( 'Could not find any test files with the given pattern(s). Create one and try again.' ) ;
47
47
}
48
48
49
49
return testFiles . map ( file => path . join ( cwd , file ) ) ;
@@ -65,7 +65,7 @@ const findTestFiles = async (typingsFilePath: string, options: Options & {config
65
65
const testDirExists = await pathExists ( path . join ( options . cwd , testDir ) ) ;
66
66
67
67
if ( testFiles . length === 0 && ! testDirExists ) {
68
- throw new Error ( `The test file \`${ testFile } \` or \`${ tsxTestFile } \` does not exist in \`${ options . cwd } \`. Create one and try again.` ) ;
68
+ throw new TsdError ( `The test file \`${ testFile } \` or \`${ tsxTestFile } \` does not exist in \`${ options . cwd } \`. Create one and try again.` ) ;
69
69
}
70
70
71
71
if ( testFiles . length === 0 ) {
@@ -84,7 +84,7 @@ export default async (options: Options = {cwd: process.cwd()}): Promise<Diagnost
84
84
const pkgResult = await readPkgUp ( { cwd : options . cwd } ) ;
85
85
86
86
if ( ! pkgResult ) {
87
- throw new Error ( `No \`package.json\` file found in \`${ options . cwd } \`. Make sure you are running the command in a Node.js project.` ) ;
87
+ throw new TsdError ( `No \`package.json\` file found in \`${ options . cwd } \`. Make sure you are running the command in a Node.js project.` ) ;
88
88
}
89
89
90
90
const pkg = pkgResult . packageJson as PackageJsonWithTsdConfig ;
0 commit comments