@@ -24,11 +24,15 @@ namespace Moduless
24
24
} ) ;
25
25
26
26
cli
27
- . command ( "call <function_name>" , "Run a specific cover function by name." )
28
- . action ( async ( function_name : string ) =>
27
+ . command ( "call <qualified_path>" , "Run a specific cover function by name, " +
28
+ "with the path to the project, in the form: /path/to/project:Name.Space.runThis" )
29
+ . action ( async ( qualified_path : string ) =>
29
30
{
30
- console . log ( "Running cover function: " + function_name ) ;
31
- await run ( function_name ) ;
31
+ const parts = qualified_path . split ( ":" ) ;
32
+ const projectPath = parts [ 0 ] ;
33
+ const functionName = parts [ 1 ] ;
34
+ console . log ( "Running cover function: " + functionName ) ;
35
+ await run ( projectPath , functionName ) ;
32
36
} ) ;
33
37
34
38
cli
@@ -75,8 +79,7 @@ namespace Moduless
75
79
/** */
76
80
async function runActive ( )
77
81
{
78
- const cwd = process . cwd ( ) ;
79
- const active = Settings . readActiveFunction ( cwd ) ;
82
+ const active = Settings . readActiveFunction ( ) ;
80
83
if ( ! active )
81
84
{
82
85
console . error ( "No active cover function has been set." ) ;
@@ -98,11 +101,18 @@ namespace Moduless
98
101
}
99
102
100
103
/** */
101
- async function run ( qualifiedName : string )
104
+ async function run ( projectPath : string , functionNameQualified : string )
102
105
{
103
- if ( 1 ) throw new Error ( "Not implemented" ) ;
106
+ const nameParts = functionNameQualified . split ( "." ) ;
107
+ const functionNamespace = nameParts . slice ( 0 , - 1 ) ;
108
+ const functionName = nameParts . slice ( - 1 ) [ 0 ] ;
109
+
110
+ await Moduless . run ( {
111
+ functionName,
112
+ functionNamespace,
113
+ projectPath,
114
+ } ) ;
104
115
105
- await Moduless . run ( { } as any ) ;
106
116
Util . separate ( ) ;
107
117
}
108
118
@@ -133,7 +143,6 @@ namespace Moduless
133
143
if ( parsed === RunGroup . all )
134
144
{
135
145
throw "Not implemented" ;
136
- run ( "" ) ;
137
146
}
138
147
139
148
else if ( parsed === RunGroup . active )
@@ -161,7 +170,7 @@ namespace Moduless
161
170
const [ x , y ] = PersistentVars . lastWindowPosition ;
162
171
const [ width , height ] = PersistentVars . lastWindowSize ;
163
172
164
- Electron . contextBridge . exposeInMainWorld ( "electron" , { require } ) ;
173
+ // Electron.contextBridge.exposeInMainWorld("electron", { require });
165
174
166
175
const window = new Electron . BrowserWindow ( {
167
176
title : "Moduless" ,
@@ -196,15 +205,28 @@ namespace Moduless
196
205
window . webContents . session . clearCache ( ) ;
197
206
window . webContents . session . clearHostResolverCache ( ) ;
198
207
199
- const indexFile = [
200
- `<!DOCTYPE html>` ,
201
- `<script src="${ __dirname } /moduless.js"></script>` ,
202
- ] . join ( "\n" ) ;
203
-
204
- const indexPath = __dirname + "/index.html" ;
205
- Fs . writeFileSync ( indexPath , indexFile ) ;
206
- const url = "file://" + indexPath + composeQueryString ( ) ;
207
- await window . webContents . loadURL ( url ) ;
208
+ let debugUrl = process . env . DEBUG_URL ;
209
+ if ( debugUrl )
210
+ {
211
+ await window . webContents . loadURL ( debugUrl ) ;
212
+ await window . webContents . executeJavaScript ( `{
213
+ const script = document.createElement("script");
214
+ script.src = "${ __filename } ";
215
+ document.head.append(script);
216
+ }` ) ;
217
+ }
218
+ else
219
+ {
220
+ const indexFile = [
221
+ `<!DOCTYPE html>` ,
222
+ `<script src="${ __filename } "></script>` ,
223
+ ] . join ( "\n" ) ;
224
+
225
+ const indexPath = __dirname + "/index.html" ;
226
+ Fs . writeFileSync ( indexPath , indexFile ) ;
227
+ const url = "file://" + indexPath + composeQueryString ( ) ;
228
+ await window . webContents . loadURL ( url ) ;
229
+ }
208
230
}
209
231
210
232
const expressionPrefix = "expression=" ;
0 commit comments