Skip to content

Instantly share code, notes, and snippets.

@feliperdamaceno
Created September 18, 2023 21:17
Show Gist options
  • Save feliperdamaceno/ed0336959e68e7525d09bd127c994cc1 to your computer and use it in GitHub Desktop.
Save feliperdamaceno/ed0336959e68e7525d09bd127c994cc1 to your computer and use it in GitHub Desktop.
A Powershell Script to easily execute JavaScript/Node helper scripts.
<#
.SYNOPSIS
Execute a JavaScript script with additional arguments.
.DESCRIPTION
This PowerShell script takes a script name and an array of script arguments, then executes the JavaScript script with those arguments.
Add the folder with the file to your PATH.
.PARAMETER scriptName
The name of the JavaScript script to execute (without .js extension).
.PARAMETER scriptArgs
A list of arguments to pass to the JavaScript script (optional).
.NOTES
File Name : exec.ps1
Author : feliperdamaceno
Prerequisite : PowerShell 5.1 or later
.EXAMPLE
exec convertToCSV example.txt
#>
param (
[string]$scriptName,
[string[]]$scriptArgs
)
# Determine the full path of the JavaScript script
$scriptPath = Join-Path -Path $PSScriptRoot -ChildPath $scriptName
# Execute the JavaScript script with additional arguments
node $scriptPath $scriptArgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment