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


##########
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(' ');

Review Comment:
   **Argument forwarding corrupts paths containing spaces.**
   
   Joining arguments with spaces and later splitting them loses shell-preserved 
boundaries. For example, `--jdkhome "/path/My JDK"` becomes three arguments. 
The previous launcher preserved the argument array. Encode the array, such as 
with JSON, across the environment-variable handoff.



-- 
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