Skip to content

AndoGhevian/VT-pkg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VT-pkg

Well, this is just a simple example of how you can support out of the box Independent Terminal Emulators for your nodejs CLI application when generating executables with npm pkg.

Generated package will work both on windows and Linux.

Table of Contest


Usage

  1. Make sure you have globally installed "pkg" module from npm.
  2. Clone repo: git clone https://github.com/AndoGhevian/VT-pkg.git
  3. Change current directory: cd VT-pkg
  4. Run packing script and get "vt-pkg" executable in current folder: npm run pkgpack
  5. Move it anywhere you want and run created executable: ./vt-pkg

You see it works from anywhere, it automatically finds and runs terminal, and executes main.js script from Internal FileSystem in this new opened terminal. Vuola!:)

Be sure to read Important Notes section!!

Important Notes

  1. If you want to access your "Internal node" from your generated by pkg executable, when trying to spawn another node process, or trying to use that "Internal node" from spawned terminal as we doe's, simply use instead of node your executable path.

    Use $ /path/to/pkg/generated-exe your-script.js, Where:

    1. /path/to/pkg/generated-exe - Replacement for original "node".
    2. your-script.js - Script which you want to execute with "Internal node" instead of your system-wide "node".
    e.g.
    const child = require('child_process')
    
    // this hold's executable path.
    const internalNode = process.execPath
    
    // when project is packed, this refer to internal filesystem.
    // See: https://www.npmjs.com/package/pkg#snapshot-filesystem
    const internalFs = __dirname 
    
    const cmdProcess = child.spawn(`${internalNode}`, [`${internalFs}/main.js`], {
        stdio: 'inherit'
    })
  2. Remember that first argument of "Internal node" if provided, must allways be existing file path, eather from your actual FileSystem or from Internal FileSystem( See Snapshot filesystem ): i.e. --arg1, -arg1, or anything else, to nonexisting file, will lead to fail for first argument.

About

Use open-term with npm 'pkg'

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published