Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
The cmd-shim npm package is designed to create command shims (or symbolic links) on Windows and Unix-like systems for node.js scripts. This allows node.js scripts to be executed as if they were native commands in the user's shell, making it easier to use node.js tools across different platforms without worrying about the underlying differences in how executable scripts are handled.
Creating command shims
This feature allows the creation of a command shim for a node.js script. The code sample demonstrates how to create a shim for a node.js script located at 'path/to/node-script.js' and place the resulting shim at 'path/to/shim'. This makes the script executable as if it were a native command.
const cmdShim = require('cmd-shim');
cmdShim('path/to/node-script.js', 'path/to/shim', function (err) {
if (err) throw err;
});
npx is a package runner tool that comes with npm. It allows you to execute any package from the npm registry without having to install it globally. While npx does not create shims, it provides a similar convenience by allowing direct execution of node.js scripts and commands. Unlike cmd-shim, npx is focused on temporary or one-off execution rather than creating a persistent executable shim.
ShellJS is a portable (Windows/Linux/OS X) implementation of Unix shell commands on top of the Node.js API. While it primarily offers a way to script shell commands within Node.js, it shares the cross-platform scripting goal with cmd-shim. However, ShellJS does not specifically focus on creating command shims but rather on providing a wide range of shell commands within Node.js scripts.
The cmd-shim used in npm to create executable scripts on Windows, since symlinks are not suitable for this purpose there.
On Unix systems, you should use a symbolic link instead.
npm install cmd-shim
Create a cmd shim at to
for the command line program at from
.
e.g.
var cmdShim = require('cmd-shim');
cmdShim(__dirname + '/cli.js', '/usr/bin/command-name').then(() => {
// shims are created!
})
The same as above, but will just continue if the file does not exist.
7.0.0 (2024-08-26)
cmd-shim
now supports node ^18.17.0 || >=20.5.0
FAQs
Used in npm for command line application support
The npm package cmd-shim receives a total of 2,688,777 weekly downloads. As such, cmd-shim popularity was classified as popular.
We found that cmd-shim demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.