@@ -43,8 +43,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
exports . findTests = findTests ;
44
44
exports . getTestEntrypoints = getTestEntrypoints ;
45
45
const fast_glob_1 = __importStar ( require ( "fast-glob" ) ) ;
46
- const fs_1 = require ( "fs" ) ;
47
- const path_1 = require ( "path" ) ;
46
+ const node_fs_1 = require ( "node: fs" ) ;
47
+ const node_path_1 = require ( "node: path" ) ;
48
48
/* Go through all patterns and find unique list of files */
49
49
async function findTests ( include , exclude , workspaceRoot , projectSourceRoot ) {
50
50
const matchingTestsPromises = include . map ( ( pattern ) => findMatchingTests ( pattern , exclude , workspaceRoot , projectSourceRoot ) ) ;
@@ -61,7 +61,7 @@ function getTestEntrypoints(testFiles, { projectSourceRoot, workspaceRoot }) {
61
61
. replace ( / ^ [ . / \\ ] + / , '' )
62
62
// Replace any path separators with dashes.
63
63
. replace ( / [ / \\ ] / g, '-' ) ;
64
- const baseName = `spec-${ ( 0 , path_1 . basename ) ( relativePath , ( 0 , path_1 . extname ) ( relativePath ) ) } ` ;
64
+ const baseName = `spec-${ ( 0 , node_path_1 . basename ) ( relativePath , ( 0 , node_path_1 . extname ) ( relativePath ) ) } ` ;
65
65
let uniqueName = baseName ;
66
66
let suffix = 2 ;
67
67
while ( seen . has ( uniqueName ) ) {
@@ -91,26 +91,26 @@ function removeRoots(path, roots) {
91
91
return path . substring ( root . length ) ;
92
92
}
93
93
}
94
- return ( 0 , path_1 . basename ) ( path ) ;
94
+ return ( 0 , node_path_1 . basename ) ( path ) ;
95
95
}
96
96
async function findMatchingTests ( pattern , ignore , workspaceRoot , projectSourceRoot ) {
97
97
// normalize pattern, glob lib only accepts forward slashes
98
98
let normalizedPattern = normalizePath ( pattern ) ;
99
99
normalizedPattern = removeLeadingSlash ( normalizedPattern ) ;
100
- const relativeProjectRoot = normalizePath ( ( 0 , path_1 . relative ) ( workspaceRoot , projectSourceRoot ) + '/' ) ;
100
+ const relativeProjectRoot = normalizePath ( ( 0 , node_path_1 . relative ) ( workspaceRoot , projectSourceRoot ) + '/' ) ;
101
101
// remove relativeProjectRoot to support relative paths from root
102
102
// such paths are easy to get when running scripts via IDEs
103
103
normalizedPattern = removeRelativeRoot ( normalizedPattern , relativeProjectRoot ) ;
104
104
// special logic when pattern does not look like a glob
105
105
if ( ! ( 0 , fast_glob_1 . isDynamicPattern ) ( normalizedPattern ) ) {
106
- if ( await isDirectory ( ( 0 , path_1 . join ) ( projectSourceRoot , normalizedPattern ) ) ) {
106
+ if ( await isDirectory ( ( 0 , node_path_1 . join ) ( projectSourceRoot , normalizedPattern ) ) ) {
107
107
normalizedPattern = `${ normalizedPattern } /**/*.spec.@(ts|tsx)` ;
108
108
}
109
109
else {
110
110
// see if matching spec file exists
111
- const fileExt = ( 0 , path_1 . extname ) ( normalizedPattern ) ;
111
+ const fileExt = ( 0 , node_path_1 . extname ) ( normalizedPattern ) ;
112
112
// Replace extension to `.spec.ext`. Example: `src/app/app.component.ts`-> `src/app/app.component.spec.ts`
113
- const potentialSpec = ( 0 , path_1 . join ) ( projectSourceRoot , ( 0 , path_1 . dirname ) ( normalizedPattern ) , `${ ( 0 , path_1 . basename ) ( normalizedPattern , fileExt ) } .spec${ fileExt } ` ) ;
113
+ const potentialSpec = ( 0 , node_path_1 . join ) ( projectSourceRoot , ( 0 , node_path_1 . dirname ) ( normalizedPattern ) , `${ ( 0 , node_path_1 . basename ) ( normalizedPattern , fileExt ) } .spec${ fileExt } ` ) ;
114
114
if ( await exists ( potentialSpec ) ) {
115
115
return [ potentialSpec ] ;
116
116
}
@@ -126,7 +126,7 @@ async function findMatchingTests(pattern, ignore, workspaceRoot, projectSourceRo
126
126
}
127
127
async function isDirectory ( path ) {
128
128
try {
129
- const stats = await fs_1 . promises . stat ( path ) ;
129
+ const stats = await node_fs_1 . promises . stat ( path ) ;
130
130
return stats . isDirectory ( ) ;
131
131
}
132
132
catch {
@@ -135,7 +135,7 @@ async function isDirectory(path) {
135
135
}
136
136
async function exists ( path ) {
137
137
try {
138
- await fs_1 . promises . access ( path , fs_1 . constants . F_OK ) ;
138
+ await node_fs_1 . promises . access ( path , node_fs_1 . constants . F_OK ) ;
139
139
return true ;
140
140
}
141
141
catch {
0 commit comments