MartinBalin commented on code in PR #24:
URL: https://github.com/apache/netbeans-vscode/pull/24#discussion_r4193359470


##########
vscode/src/nbcode.ts:
##########
@@ -97,30 +98,67 @@ if (typeof process === 'object' && typeof process.argv0 
==='string' && process.a
     let args = process.argv.slice(2);
     let json = JSON.parse("" + fs.readFileSync(path.join(extension, 
'package.json')));
     let storage;
-    
-    if (!env.nbcode_userdir || env.nbcode_userdir == 'global') {
-        storage = path.join(os.platform() === 'darwin' ? 
-                path.join(os.homedir(), 'Library', 'Application Support') :
-                path.join(os.homedir(), '.config'),
-                'Code', 'User', 'globalStorage', json.publisher + '.' + 
json.name);
+    let datadir;
+    if (!env.nbcode_userdir) {
+        datadir= path.join(process.cwd(), "out", "userdir");
+        storage = path.join(datadir, json.publisher + '.' + json.name);
+    } else if (env.nbcode_userdir == 'global') {
+        if (os.platform() === 'darwin') {
+            datadir = path.join(os.homedir(), 'Library', 'Application 
Support');
+        } else {
+            datadir = path.join(os.homedir(), '.config', 'Code', 'User', 
'globalStorage');
+        }
+        storage = path.join(datadir, json.publisher + '.' + json.name);
     } else {
+        datadir= path.join(process.cwd(), "out", "userdir");
         storage = env.nbcode_userdir;
     }
-    console.log('Launching NBLS with user directory: ' + storage)
-    let info = {
-        clusters : clusters,
-        extensionPath: extension,
-        storagePath : storage,
-        jdkHome : null
-    };
-    let p = launch(info, ...args);
-    p.stdout.on('data', function(data) {
+    let extdir = path.join(process.cwd(), "out", "extdir")
+    let codeArgs = [
+        "--extensionDevelopmentPath=" + process.cwd(),
+        "--user-data-dir=" + datadir,
+        "--extensions-dir=" + extdir
+    ];
+    let extraEnv: NodeJS.ProcessEnv = env.netbeans_debug ? {
+        // no override of netbeans_debug
+    } : {
+        netbeans_debug : 
'-J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000'
+    }
+    extraEnv.netbeans_args = args.join(' ');
+    console.log('Launching `code` with following arguments:');
+    for (var arg of codeArgs) {
+        console.log(`  ${arg}`);
+    }
+    {
+        let first = true;
+        for (var name in extraEnv) {
+            if (first) {
+                console.log('and following additional environment variables:');
+                first = false;
+            }
+            console.log(`  ${name}=${extraEnv[name]}`);
+        }
+    }
+
+    let codeProc: ChildProcessByStdio<any, Readable, Readable> = spawn("code", 
codeArgs, {

Review Comment:
   Sorry something new popped up. The new launcher cannot invoke the standard 
Windows code command.
   `spawn("code", codeArgs, …)` runs without a shell. VS Code supplies its 
Windows CLI as 
[code.cmd](https://github.com/microsoft/vscode/blob/main/resources/win32/bin/code.cmd),
 which requires a command interpreter. Consequently, `npm run nbcode` fails on 
a standard Windows installation before starting the editor. Add 
Windows-specific command invocation while preserving argument quoting. This 
follows [Node’s documented process-launch 
behavior](https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows);
 I haven’t reproduced it on Windows.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to