@tuckn/wsh-packager
v1.0.1
Published
Node.js CLI to package WSH scripts that are defined in a Windows Script File (.wsf) into one WSH file.
Downloads
12
Maintainers
Readme
Node.js: wsh-packager
Node.js CLI to bundle WSH scripts (.js, .vbs) that are defined in a Windows Script File (.wsf). WSH is an abbreviation for Windows Script Host.
Installation
npm install -g @tuckn/wsh-packager
or download a released binary file.
Usage
> wsh-packager bundle --help
Usage: wsh-packager bundle [options] <dirPath>
Bundles .js, .vbs (WSH scripts) files defined in .wsf file.
Options:
-V, --version output the version number
-J, --job-id <RegExp> A job id to be bundled (Default: "\.(js|vbs|wsf)$").
-D, --base-dir <path> Default is the <dirPath>
-I, --ignore-src <RegExp> Ex. "main\.js$"
-h, --help display help for command
Basic Example
D:\MyWshFolder\
├─ Package.wsf
└─ src\
├─ Function.js
├─ Object.js
└─ JSON.js
Package.wsf is
<package>
<job id = "./dist/JSON.min.js">
<script language="JScript" src="./src/Function.js"></script>
<script language="JScript" src="./src/Object.js"></script>
<script language="JScript" src="./src/JSON.js"></script>
</job>
</package>
and execute the below command.
> wsh-packager bundle "D:\MyWshFolder"
The result
D:\MyWshFolder\
├─ Package.wsf
├─ dist\
│ └─ JSON.min.js
└─ src\
├─ Function.js
├─ Object.js
└─ JSON.js
The created JSON.min.js is packed with the three .js files that are minified.
Multiple Jobs Packaging
D:\MyWshFolder\
├─ Package.wsf
└─ src\
├─ CLI.js
├─ Excel.vbs
├─ Function.js
├─ Object.js
├─ JSON.js
└─ Util.vbs
Package.wsf is
<package>
<job id = "./dist/MyModule.vbs">
<script language="VBScript" src="./src/Util.vbs"></script>
<script language="VBScript" src="./src/Excel.vbs"></script>
</job>
<job id = "./dist/JSON.min.js">
<script language="JScript" src="./src/Function.js"></script>
<script language="JScript" src="./src/Object.js"></script>
<script language="JScript" src="./src/JSON.js"></script>
</job>
<job id = "./dist/Run.wsf">
<script language="JScript" src="./src/Function.js"></script>
<script language="VBScript" src="./src/Excel.vbs"></script>
<script language="JScript" src="./src/CLI.js"></script>
</job>
</package>
and execute the below command.
> wsh-packager bundle "D:\MyWshFolder"
The result
D:\MyWshFolder\
├─ Package.wsf
├─ dist\
│ ├─ JSON.min.js
│ ├─ MyModule.vbs
│ └─ Run.wsf
└─ src\
├─ CLI.js
├─ Excel.vbs
├─ Function.js
├─ Object.js
├─ JSON.js
└─ Util.vbs
Run.wsf is an executable file on Windows of most versions.
> cscript //nologo "D:\MyWshFolder\dist\Run.wsf"
Documentation
See all specifications here.
License
MIT
Copyright (c) 2020 Tuckn