@@ -20,10 +20,7 @@ define(function (require, exports, module) {
2020 Menus = brackets . getModule ( "command/Menus" ) ,
2121 NodeConnector = brackets . getModule ( "NodeConnector" ) ;
2222
23- const nodeConnector = NodeConnector . createNodeConnector (
24- "your-extension-id-1" ,
25- exports
26- ) ;
23+ let nodeConnector ;
2724
2825 async function fetchImage ( ) {
2926 const imageUrl = "https://picsum.photos/536/354" ;
@@ -40,6 +37,10 @@ define(function (require, exports, module) {
4037
4138 // Function to run when the menu item is clicked
4239 async function handleHelloWorld ( ) {
40+ if ( ! Phoenix . isNativeApp ) {
41+ alert ( "Node Features only works in desktop apps." ) ;
42+ return ;
43+ }
4344 let html = "<b>Image conversion failed</b>" ;
4445 try {
4546 alert ( "downloading image..." ) ;
@@ -86,6 +87,10 @@ define(function (require, exports, module) {
8687 console . log ( "hello world" ) ;
8788
8889 if ( Phoenix . isNativeApp ) {
90+ nodeConnector = NodeConnector . createNodeConnector (
91+ "your-extension-id-1" ,
92+ exports
93+ ) ;
8994 // you can also execute nodejs code in dekstop builds
9095 // below code will execute the function `echoTest` defined in `node/index.js`
9196 nodeConnector . execPeer ( "echoTest" , "yo!" ) . then ( console . log ) ;
0 commit comments