@@ -31,12 +31,12 @@ const findElixirProjectPath = async (editorPath) => {
31
31
const editorDir = dirname ( editorPath ) ;
32
32
const mixexsPath = find ( editorDir , 'mix.exs' ) ;
33
33
if ( mixexsPath !== null ) {
34
- const pathArray = mixexsPath . split ( '/' ) ;
34
+ const pathArray = mixexsPath . split ( sep ) ;
35
35
if ( pathArray . length > 3 && pathArray [ pathArray . length - 3 ] === 'apps' ) {
36
36
// Treat this as an umbrella app. This may be wrong -
37
37
// If you happen to keep your code in a directory called 'apps'
38
38
pathArray . splice ( ( pathArray . length - 3 ) , 3 ) ;
39
- const umbrellaProjectPath = pathArray . join ( '/' ) ;
39
+ const umbrellaProjectPath = pathArray . join ( sep ) ;
40
40
41
41
// Safety check by looking for a `mix.exs` file in the same directory as
42
42
// 'apps'. If it exists, then it's likely an umbrella project
@@ -68,11 +68,21 @@ const isMixProject = async (filePath) => {
68
68
return existsSync ( join ( project , 'mix.exs' ) ) ;
69
69
} ;
70
70
71
+ const isUmbrellaProject = async ( filePath ) => {
72
+ const project = await elixirProjectPath ( filePath ) ;
73
+ return existsSync ( join ( project , 'apps' ) ) ;
74
+ }
75
+
71
76
const isTestFile = async ( filePath ) => {
72
77
const project = await elixirProjectPath ( filePath ) ;
73
78
const relativePath = relative ( project , filePath ) ;
74
- // Is the first directory of the relative path "test"?
75
- return relativePath . split ( sep ) [ 0 ] === 'test' ;
79
+ if ( isUmbrellaProject ( ) ) {
80
+ // Is the structure "apps/app_name/test/..."
81
+ return relativePath . split ( sep ) [ 2 ] === 'test' ;
82
+ } else {
83
+ // Is the structure "test/..."
84
+ return relativePath . split ( sep ) [ 0 ] === 'test' ;
85
+ }
76
86
} ;
77
87
78
88
const isForcedElixirc = ( ) => forceElixirc ;
0 commit comments