Socket
Socket
Sign inDemoInstall

@vercel/build-utils

Package Overview
Dependencies
Maintainers
9
Versions
311
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/build-utils - npm Package Compare versions

Comparing version 6.7.5 to 6.8.0

6

CHANGELOG.md
# @vercel/build-utils
## 6.8.0
### Minor Changes
- Add `getNodeBinPaths()` and `traverseUpDirectories()` functions ([#10150](https://github.com/vercel/vercel/pull/10150))
## 6.7.5

@@ -4,0 +10,0 @@

25

dist/fs/run-user-scripts.d.ts

@@ -30,13 +30,13 @@ /// <reference types="node" />

}
export interface WalkParentDirsProps {
export interface TraverseUpDirectoriesProps {
/**
* The highest directory, typically the workPath root of the project.
* If this directory is reached and it doesn't contain the file, null is returned.
* The directory to start iterating from, typically the same directory of the entrypoint.
*/
base: string;
start: string;
/**
* The directory to start searching, typically the same directory of the entrypoint.
* If this directory doesn't contain the file, the parent is checked, etc.
* The highest directory, typically the workPath root of the project.
*/
start: string;
base?: string;
}
export interface WalkParentDirsProps extends Required<TraverseUpDirectoriesProps> {
/**

@@ -47,2 +47,8 @@ * The name of the file to search for, typically `package.json` or `Gemfile`.

}
export interface WalkParentDirsMultiProps extends Required<TraverseUpDirectoriesProps> {
/**
* The name of the file to search for, typically `package.json` or `Gemfile`.
*/
filenames: string[];
}
export interface SpawnOptionsExtended extends SpawnOptions {

@@ -63,5 +69,10 @@ /**

export declare function execCommand(command: string, options?: SpawnOptions): Promise<boolean>;
export declare function traverseUpDirectories({ start, base, }: TraverseUpDirectoriesProps): Generator<string, void, unknown>;
/**
* @deprecated Use `getNodeBinPaths()` instead.
*/
export declare function getNodeBinPath({ cwd, }: {
cwd: string;
}): Promise<string>;
export declare function getNodeBinPaths({ start, base, }: TraverseUpDirectoriesProps): string[];
export declare function runShellScript(fsPath: string, args?: string[], spawnOpts?: SpawnOptions): Promise<boolean>;

@@ -68,0 +79,0 @@ export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.installDependencies = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runPackageJsonScript = exports.runCustomInstallCommand = exports.getEnvForPackageManager = exports.runNpmInstall = exports.walkParentDirs = exports.scanParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.spawnAsync = void 0;
exports.installDependencies = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runPackageJsonScript = exports.runCustomInstallCommand = exports.getEnvForPackageManager = exports.runNpmInstall = exports.walkParentDirs = exports.scanParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPaths = exports.getNodeBinPath = exports.traverseUpDirectories = exports.execCommand = exports.spawnCommand = exports.spawnAsync = void 0;
const assert_1 = __importDefault(require("assert"));

@@ -67,2 +67,18 @@ const fs_extra_1 = __importDefault(require("fs-extra"));

exports.execCommand = execCommand;
function* traverseUpDirectories({ start, base, }) {
let current = path_1.default.normalize(start);
const normalizedRoot = base ? path_1.default.normalize(base) : undefined;
while (current) {
yield current;
if (current === normalizedRoot)
break;
// Go up one directory
const next = path_1.default.join(current, '..');
current = next === current ? undefined : next;
}
}
exports.traverseUpDirectories = traverseUpDirectories;
/**
* @deprecated Use `getNodeBinPaths()` instead.
*/
async function getNodeBinPath({ cwd, }) {

@@ -74,2 +90,6 @@ const { lockfilePath } = await scanParentDirs(cwd);

exports.getNodeBinPath = getNodeBinPath;
function getNodeBinPaths({ start, base, }) {
return Array.from(traverseUpDirectories({ start, base })).map(dir => path_1.default.join(dir, 'node_modules/.bin'));
}
exports.getNodeBinPaths = getNodeBinPaths;
async function chmodPlusX(fsPath) {

@@ -200,5 +220,4 @@ const s = await fs_extra_1.default.stat(fsPath);

(0, assert_1.default)(path_1.default.isAbsolute(start), 'Expected "start" to be absolute path');
let parent = '';
for (let current = start; base.length <= current.length; current = parent) {
const fullPath = path_1.default.join(current, filename);
for (const dir of traverseUpDirectories({ start, base })) {
const fullPath = path_1.default.join(dir, filename);
// eslint-disable-next-line no-await-in-loop

@@ -208,7 +227,2 @@ if (await fs_extra_1.default.pathExists(fullPath)) {

}
parent = path_1.default.dirname(current);
if (parent === current) {
// Reached root directory of the filesystem
break;
}
}

@@ -219,5 +233,4 @@ return null;

async function walkParentDirsMulti({ base, start, filenames, }) {
let parent = '';
for (let current = start; base.length <= current.length; current = parent) {
const fullPaths = filenames.map(f => path_1.default.join(current, f));
for (const dir of traverseUpDirectories({ start, base })) {
const fullPaths = filenames.map(f => path_1.default.join(dir, f));
const existResults = await Promise.all(fullPaths.map(f => fs_extra_1.default.pathExists(f)));

@@ -228,7 +241,2 @@ const foundOneOrMore = existResults.some(b => b);

}
parent = path_1.default.dirname(current);
if (parent === current) {
// Reached root directory of the filesystem
break;
}
}

@@ -235,0 +243,0 @@ return [];

@@ -11,3 +11,3 @@ import FileBlob from './file-blob';

import rename from './fs/rename';
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getSpawnOptions, getNodeBinPath, scanParentDirs } from './fs/run-user-scripts';
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
import { getLatestNodeVersion, getDiscontinuedNodeVersions } from './fs/node-version';

@@ -22,3 +22,3 @@ import streamToBuffer from './fs/stream-to-buffer';

import { validateNpmrc } from './validate-npmrc';
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, validateNpmrc, };
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
export { EdgeFunction } from './edge-function';

@@ -25,0 +25,0 @@ export { readConfigFile } from './fs/read-config-file';

{
"name": "@vercel/build-utils",
"version": "6.7.5",
"version": "6.8.0",
"license": "Apache-2.0",

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

Sorry, the diff of this file is too big to display

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