🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

nano-spawn

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-spawn - npm Package Compare versions

Comparing version

to
1.0.1

7

package.json
{
"name": "nano-spawn",
"version": "1.0.0",
"version": "1.0.1",
"description": "Tiny process execution for humans — a better child_process",

@@ -65,4 +65,7 @@ "license": "MIT",

"concurrency": 1,
"timeout": "240s"
"timeout": "240s",
"require": [
"./test/helpers/setup.js"
]
}
}

@@ -1,2 +0,2 @@

import {access} from 'node:fs/promises';
import fs from 'node:fs/promises';
import path from 'node:path';

@@ -24,3 +24,2 @@ import process from 'node:process';

// Environment variables are case-insensitive on Windows, so we check both `PATH` and `Path`.
// eslint-disable-next-line no-return-assign
const isExe = (file, cwd, {Path = '', PATH = Path}) =>

@@ -30,9 +29,13 @@ // If the *.exe or *.com file extension was not omitted.

exeExtensions.some(extension => file.toLowerCase().endsWith(extension))
// Use returned assignment to keep code small
|| (EXE_MEMO[`${file}\0${cwd}\0${PATH}`] ??= mIsExe(file, cwd, PATH));
|| mIsExe(file, cwd, PATH);
// Memoize the following function, for performance
// Memoize the `mIsExe` and `fs.access`, for performance
const EXE_MEMO = {};
// eslint-disable-next-line no-return-assign
const memoize = function_ => (...arguments_) =>
// Use returned assignment to keep code small
EXE_MEMO[arguments_.join('\0')] ??= function_(...arguments_);
const mIsExe = async (file, cwd, PATH) => {
const access = memoize(fs.access);
const mIsExe = memoize(async (file, cwd, PATH) => {
const parts = PATH

@@ -49,4 +52,4 @@ // `PATH` is ;-separated on Windows

await Promise.any(
exeExtensions.flatMap(extension => [cwd, ...parts]
.map(part => access(`${path.resolve(part, file)}${extension}`)),
[cwd, ...parts].flatMap(part => exeExtensions
.map(extension => access(`${path.resolve(part, file)}${extension}`)),
),

@@ -59,3 +62,3 @@ );

return true;
};
});

@@ -62,0 +65,0 @@ // Other file extensions require using a shell