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.8 to 1.2.9

6

lib/command-exists.js

@@ -65,3 +65,4 @@ 'use strict';

var commandExistsWindows = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
// Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator
if (!(/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(commandName))) {
callback(null, false);

@@ -97,3 +98,4 @@ return;

var commandExistsWindowsSync = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
// Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator
if (!(/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(commandName))) {
return false;

@@ -100,0 +102,0 @@ }

{
"name": "command-exists",
"version": "1.2.8",
"version": "1.2.9",
"description": "check whether a command line command exists in the current environment",

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

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

var commandExistsSync = commandExists.sync;
var resolve = require('path').resolve;
var isUsingWindows = process.platform == 'win32'

@@ -11,6 +12,6 @@

describe('async - callback', function() {
it('it should find a command named ls or dir', function(done){
it('it should find a command named ls or xcopy', function(done){
var commandToUse = 'ls'
if (isUsingWindows) {
commandToUse = 'dir'
commandToUse = 'xcopy'
}

@@ -35,6 +36,6 @@

describe('async - promise', function() {
it('it should find a command named ls or dir', function(done){
it('it should find a command named ls or xcopy', function(done){
var commandToUse = 'ls'
if (isUsingWindows) {
commandToUse = 'dir'
commandToUse = 'xcopy'
}

@@ -62,6 +63,6 @@

describe('sync', function() {
it('it should find a command named ls or dir', function(){
it('it should find a command named ls or xcopy', function(){
var commandToUse = 'ls'
if (isUsingWindows) {
commandToUse = 'dir'
commandToUse = 'xcopy'
}

@@ -75,6 +76,6 @@ expect(commandExistsSync(commandToUse)).to.be(true);

it('it should not find a command named ls or dir prefixed with some nonsense', function(){
it('it should not find a command named ls or xcopy prefixed with some nonsense', function(){
var commandToUse = 'fdsafdsa ls'
if (isUsingWindows) {
commandToUse = 'fdsafdsaf dir'
commandToUse = 'fdsafdsaf xcopy'
}

@@ -135,2 +136,18 @@ expect(commandExistsSync(commandToUse)).to.be(false);

});
describe('absolute path', function() {
it('it should report true if there is a command with that name in absolute path', function(done) {
var commandToUse = resolve('test/executable-script.js');
commandExists(commandToUse)
.then(function(command){
expect(command).to.be(commandToUse);
done();
});
});
it('it should report false if there is not a command with that name in absolute path', function() {
var commandToUse = resolve('executable-script.js');
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