The plugin
provides general support for authoring npx
scripts (javascript
files that include npx
in the shebang
(e.g. #!/usr/bin/env -S npx {module}
). The support includes:
- Snippet for authoring
npx
shebangs - Type acquisition for easier authoring
- Support for launching scripts (with performance enhancement)
This is a sister project of @arcsine/nodesh
, but is intended to be generic enough to support any other libraries that that work as an npx
script.
#!/usr/bin/env -S npx @arcsine/nodesh
/// @ts-check
/// <reference types="/tmp/npx-scripts/arcsine.nodesh" lib="npx-scripts" />
'https://en.wikipedia.org/wiki/Special:Random'
.$http()
.$tokens(/\b[A-Z][a-z]+\b/) // Read proper names
.$console;
When authoring a new script, the shebang
snippet will help to provide a shebang. The shebang has everything necessary except for the npm
module that the script will run with.
The nodesh-shebang
will provide support for a nodesh
declaration.
During the editing process, the plugin will attempt to assist with acquiring types. If a file with an npx
shebang is opened, or an npx
shebang is added to a file, the plugin will check the referenced npm
module. If the module contains types, the user will be prompted to add a type reference to the script.
If a script is opened that already has the typing information in it, the plugin will alert the user to the invalid typings, and offer to fix them.
The extension will honor any module with a version specified #!/usr/bin/env -S npx @arcsine/[email protected]
. Multiple versions can be installed side-by-side without issue and the extension will manage them appropriately.
If a file is loaded that happens to have an existing reference (/// <reference />
), the plugin will check the path, and if it is not found it will be updated with a fresh install. When closing a document within vscode, the all inserted text will be stripped out.
Given the context of executable scripts, you can run the script manually without problem. Additionally, the plugin provides the ability to execute the script with the loaded module, which will stream the output to an output channel. One of the primary benefits here, is that npx will not be invoked, and so installation will be skipped. This provides a speed boost across multiple executions.
Additionally, there is a command to Run Script With Input
, which will prompt for a file to use as stdin for the script execution.
NOTE: To get colorized output from the script runner, consider installing the Output Colorizer extension.
- Change to how we indicate scripts are running, no longer blocking output with progress indicator.
- Minor tweak to output channel management for running scripts
- Updating logo
- Standardized naming on
npx-scripts
- Resolved issue with
require
caching modules
- Documentation update
- Resolved issues with reinstallation
- Change general flow of plugin, no long attempts to auto add typings
- Allow for manual adding/removal/verifying of typings
- Utilizes code lens for a less obtrusive interface
- Provides editor title bar quick actions for running scripts
- Supports running scripts with a file as stdin
- Resolved formatting issues when cleaning file on close
- Changed preamble use triple slash, and work with formatters better
- Fixed bugs with previous process writing to new output
- Allow for more flexible detection of line equality, should work better with formatters
- Separated out tag line from typedef for better support with formatters
- Moved output from terminal to OutputChannel
- Allow for full reinstall of managed modules
- General refactor
- General refactor
- Support cleaning up files on close, leaving files as found
- Updated general documentation
- Migrated naming from
npx-types
tonpx-scripts
to better reflect the scope of the plugin.
- Support for library versions as specified in npx command
- Allow for running scripts via command
npx: Run npx script
- Initial Release