New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

command-exists

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-exists - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

test/executable-script.cmd

20

lib/command-exists.js

@@ -6,2 +6,3 @@ 'use strict';

var fs = require('fs');
var path = require('path');
var access = fs.access;

@@ -65,2 +66,6 @@ var accessSync = fs.accessSync;

var commandExistsWindows = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
callback(null, false);
return;
}
var child = exec('where ' + cleanedCommandName,

@@ -93,2 +98,5 @@ function (error) {

var commandExistsWindowsSync = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
return false;
}
try {

@@ -111,2 +119,14 @@ var stdout = execSync('where ' + cleanedCommandName, {stdio: []});

if (isUsingWindows) {
cleanInput = function(s) {
var isPathName = /[\\]/.test(s);
if (isPathName) {
var dirname = '"' + path.dirname(s) + '"';
var basename = '"' + path.basename(s) + '"';
return dirname + ':' + basename;
}
return '"' + s + '"';
}
}
module.exports = function commandExists(commandName, callback) {

@@ -113,0 +133,0 @@ var cleanedCommandName = cleanInput(commandName);

2

package.json
{
"name": "command-exists",
"version": "1.2.7",
"version": "1.2.8",
"description": "check whether a command line command exists in the current environment",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -57,2 +57,6 @@ command-exists

### v1.2.7
Removes unnecessary printed output on windows.
### v1.2.6

@@ -59,0 +63,0 @@

@@ -113,3 +113,19 @@ 'use strict';

}
if (isUsingWindows) {
it('it should report true if there is an executable file with that name', function(done) {
var commandToUse = 'test\\executable-script.cmd'
commandExists(commandToUse)
.then(function(command){
expect(command).to.be(commandToUse);
done();
});
});
it('it should report false if there is a double quotation mark in the file path', function() {
var commandToUse = 'test\\"executable-script.cmd'
expect(commandExists.sync(commandToUse)).to.be(false);
});
}
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc