dsheiko / nw-autoupdater

⛔️ [DEPRECATED] Library provides low-level API to control NW.js app auto-updates
MIT License
75 stars 36 forks source link

Callback fuction not defined in nodejs - chmod inside linux.js(Version - 1.1.11) #52

Open Piyush5767 opened 3 years ago

Piyush5767 commented 3 years ago

Received error while relaunches the downloaded release

The linux.js(nw-autoupdater/Lib/Swap/Linux.js) Library - extract function is using Nodejs chmod function whereas the call back function is not defined and the script is generating a type error.

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
    at makeCallback (fs.js:161:11)
    at Object.chmod (fs.js:1218:14)
    at SwapLinux.extractScript (/tmp/.io.nwjs.islKfA/node_modules/nw-autoupdater/Lib/Swap/Linux.js:19:8)

We are receiving the error when nw-autoupdater is trying to restart the node WebKit application after its downloads and installed the files from the server. Also, this issue appears only in linux OS for Windows it's working fine. For the reference below I have defined the extract function which is used by linux.js

  extractScript( homeDir )
  {
    let content = this.getScriptContent() + `
echo " "
echo "$APP_PATH/\${RUNNER}&"
"$APP_PATH/\${RUNNER}"&`,
        scriptPath = join( homeDir, "swap.sh" );
    fs.writeFileSync( scriptPath, content, "utf8" );
    fs.chmod( scriptPath, 511 ); // 755
    this.scriptPath = scriptPath;
  }
Piyush5767 commented 3 years ago

Adding callback fixes the type error and installed the files, whereas It is still not able to load the application in Linux.

 fs.chmod( scriptPath, 0o775,(err) => {
    if (err) throw err;
 });