@@ -31,6 +31,19 @@ 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 ( sep ) ;
35
+ if ( pathArray . length > 3 && pathArray [ pathArray . length - 3 ] === 'apps' ) {
36
+ // Treat this as an umbrella app. This may be wrong -
37
+ // If you happen to keep your code in a directory called 'apps'
38
+ pathArray . splice ( ( pathArray . length - 3 ) , 3 ) ;
39
+ const umbrellaProjectPath = pathArray . join ( sep ) ;
40
+
41
+ // Safety check by looking for a `mix.exs` file in the same directory as
42
+ // 'apps'. If it exists, then it's likely an umbrella project
43
+ if ( existsSync ( join ( umbrellaProjectPath , 'mix.exs' ) ) ) {
44
+ return umbrellaProjectPath ;
45
+ }
46
+ }
34
47
return dirname ( mixexsPath ) ;
35
48
}
36
49
const projPath = atom . project . relativizePath ( editorPath ) [ 0 ] ;
@@ -55,10 +68,19 @@ const isMixProject = async (filePath) => {
55
68
return existsSync ( join ( project , 'mix.exs' ) ) ;
56
69
} ;
57
70
71
+ const isUmbrellaProject = async ( filePath ) => {
72
+ const project = await elixirProjectPath ( filePath ) ;
73
+ return existsSync ( join ( project , 'apps' ) ) ;
74
+ } ;
75
+
58
76
const isTestFile = async ( filePath ) => {
59
77
const project = await elixirProjectPath ( filePath ) ;
60
78
const relativePath = relative ( project , filePath ) ;
61
- // Is the first directory of the relative path "test"?
79
+ if ( isUmbrellaProject ( filePath ) ) {
80
+ // Is the structure "apps/app_name/test/..."
81
+ return relativePath . split ( sep ) [ 2 ] === 'test' ;
82
+ }
83
+ // Is the structure "test/..."
62
84
return relativePath . split ( sep ) [ 0 ] === 'test' ;
63
85
} ;
64
86
0 commit comments