@@ -5,7 +5,7 @@ import globby from 'globby';
55import { getDiagnostics as getTSDiagnostics } from './compiler' ;
66import loadConfig from './config' ;
77import getCustomDiagnostics from './rules' ;
8- import { Context , Config , Diagnostic , PackageJsonWithTsdConfig } from './interfaces' ;
8+ import { Context , Config , Diagnostic , PackageJsonWithTsdConfig , TsdError } from './interfaces' ;
99
1010export interface Options {
1111 cwd : string ;
@@ -25,7 +25,7 @@ const findTypingsFile = async (pkg: PackageJsonWithTsdConfig, options: Options):
2525 const typingsExist = await pathExists ( typingsPath ) ;
2626
2727 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.` ) ;
2929 }
3030
3131 return typings ;
@@ -43,7 +43,7 @@ const findCustomTestFiles = async (testFilesPattern: readonly string[], cwd: str
4343 const testFiles = await globby ( testFilesPattern , { cwd} ) ;
4444
4545 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.' ) ;
4747 }
4848
4949 return testFiles . map ( file => path . join ( cwd , file ) ) ;
@@ -65,7 +65,7 @@ const findTestFiles = async (typingsFilePath: string, options: Options & {config
6565 const testDirExists = await pathExists ( path . join ( options . cwd , testDir ) ) ;
6666
6767 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.` ) ;
6969 }
7070
7171 if ( testFiles . length === 0 ) {
@@ -84,7 +84,7 @@ export default async (options: Options = {cwd: process.cwd()}): Promise<Diagnost
8484 const pkgResult = await readPkgUp ( { cwd : options . cwd } ) ;
8585
8686 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.` ) ;
8888 }
8989
9090 const pkg = pkgResult . packageJson as PackageJsonWithTsdConfig ;
0 commit comments