builder-util
- Version 26.15.3
- Published
- 174 kB
- 14 dependencies
- MIT license
Install
npm i builder-utilyarn add builder-utilpnpm add builder-utilOverview
Overview not available.
Index
Variables
Functions
- addValue()
- archFromString()
- buildGotProxyAgent()
- copyDir()
- copyFile()
- copyOrLinkFile()
- decodeCscLinkBase64()
- defaultArchFromString()
- dirSize()
- DO_NOT_USE_HARD_LINKS()
- doSpawn()
- exec()
- executeFinally()
- exists()
- filterSensitiveEnv()
- generateKsuid()
- getArchCliNames()
- getArchSuffix()
- getArtifactArchName()
- getPlatformIconFileName()
- getUserDefinedCacheDir()
- isArrayEqualRegardlessOfSort()
- isEmptyOrSpaces()
- isEnvTrue()
- isPullRequest()
- isTokenCharValid()
- loadCscLink()
- orIfFileNotExist()
- orNullIfFileNotExist()
- parseValidEnvVarUrl()
- printErrorAndExit()
- removeNullish()
- removePassword()
- replaceDefault()
- resolveCscLinkPath()
- resolveEnvShellValue()
- resolveEnvToolsetPath()
- sanitizeDirPath()
- serializeToYaml()
- setPrinter()
- spawn()
- spawnAndWrite()
- spawnAndWriteWithOutput()
- statOrNull()
- stripSensitiveEnvVars()
- to7zaOutputSwitch()
- toLinuxArchString()
- unlinkIfExists()
- use()
- USE_HARD_LINKS()
- walk()
Classes
Interfaces
Enums
Type Aliases
Variables
variable debug
const debug: _debug.Debugger;variable debug7z
const debug7z: _debug.Debugger;variable httpExecutor
const httpExecutor: NodeHttpExecutor;variable log
const log: Logger;variable MAX_FILE_REQUESTS
const MAX_FILE_REQUESTS: number;variable PADDING
const PADDING: number;variable shouldDisableNonErrorLoggingVitest
const shouldDisableNonErrorLoggingVitest: boolean | '';Functions
function addValue
addValue: <K, T>(map: Map<K, Array<T>>, key: K, value: T) => void;function archFromString
archFromString: (name: string) => Arch;function buildGotProxyAgent
buildGotProxyAgent: () => | { http?: HttpProxyAgent<string>; https?: HttpsProxyAgent<string> } | undefined;function copyDir
copyDir: ( src: string, destination: string, options?: CopyDirOptions) => Promise<any>;Empty directories is never created. Hard links is used if supported and allowed.
function copyFile
copyFile: (src: string, dest: string, isEnsureDir?: boolean) => Promise<any>;function copyOrLinkFile
copyOrLinkFile: ( src: string, dest: string, stats?: Stats | null, isUseHardLink?: boolean, exDevErrorHandler?: (() => boolean) | null) => Promise<any>;Hard links is used if supported and allowed. File permission is fixed — allow execute for all if owner can, allow read for all if owner can.
ensureDir is not called, dest parent dir must exists
function decodeCscLinkBase64
decodeCscLinkBase64: (link: string) => Buffer | null;Decodes a base64 CSC link to a Buffer, or returns null if the value is not base64.
function defaultArchFromString
defaultArchFromString: (name?: string) => Arch;function dirSize
dirSize: (dirPath: string) => Promise<number>;function DO_NOT_USE_HARD_LINKS
DO_NOT_USE_HARD_LINKS: (file: string) => boolean;function doSpawn
doSpawn: ( command: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions) => ChildProcess;function exec
exec: ( file: string, args?: Array<string> | null, options?: ExecFileOptions, isLogOutIfDebug?: boolean) => Promise<string>;function executeFinally
executeFinally: <T>( promise: Promise<T>, task: (isErrorOccurred: boolean) => Promise<any>) => Promise<T>;function exists
exists: (file: string) => Promise<boolean>;function filterSensitiveEnv
filterSensitiveEnv: ( env: Record<string, string | undefined>) => Record<string, string | undefined>;function generateKsuid
generateKsuid: () => string;Generates a K-Sortable Unique Identifier (KSUID): a 27-char base62 string encoding 4 bytes of timestamp + 16 bytes of random data. Compatible with https://github.com/segmentio/ksuid
function getArchCliNames
getArchCliNames: () => Array<string>;function getArchSuffix
getArchSuffix: (arch: Arch, defaultArch?: string) => string;function getArtifactArchName
getArtifactArchName: (arch: Arch, ext: string) => string;function getPlatformIconFileName
getPlatformIconFileName: ( value: string | Nullish, isMac: boolean) => string | null | undefined;function getUserDefinedCacheDir
getUserDefinedCacheDir: () => Promise<string | undefined>;function isArrayEqualRegardlessOfSort
isArrayEqualRegardlessOfSort: (a: Array<string>, b: Array<string>) => boolean;function isEmptyOrSpaces
isEmptyOrSpaces: (s: string | Nullish) => s is any;function isEnvTrue
isEnvTrue: (value: string | Nullish) => boolean;function isPullRequest
isPullRequest: () => boolean | '' | undefined;function isTokenCharValid
isTokenCharValid: (token: string) => boolean;function loadCscLink
loadCscLink: (link: string, resourcesDir: string | undefined) => Promise<string>;Resolves a CSC link to its text content.
Formats accepted: - Base64: detected by
data:…;base64,prefix, length > 2048, or trailing=- File path:~/…,file://…, absolute, or relative tocwd
function orIfFileNotExist
orIfFileNotExist: <T>(promise: Promise<T>, fallbackValue: T) => Promise<T>;function orNullIfFileNotExist
orNullIfFileNotExist: <T>(promise: Promise<T>) => Promise<T | null>;function parseValidEnvVarUrl
parseValidEnvVarUrl: (envVarName: string, allowHttp?: boolean) => string | null;function printErrorAndExit
printErrorAndExit: (error: Error) => void;function removeNullish
removeNullish: <T>(obj: T) => T;Recursively removes all undefined and null values from an object
function removePassword
removePassword: (input: string) => string;function replaceDefault
replaceDefault: ( inList: Array<string> | Nullish, defaultList: Array<string>) => Array<string>;function resolveCscLinkPath
resolveCscLinkPath: ( cscLink: string, resourcesDir: string | undefined) => string;Resolves a CSC link file path, expanding
~/,file://, and relative paths againstcwd.
function resolveEnvShellValue
resolveEnvShellValue: (envVarName: string) => string | null;function resolveEnvToolsetPath
resolveEnvToolsetPath: ( envVarKey: string, expectedType: 'directory' | 'file') => Promise<string | null>;function sanitizeDirPath
sanitizeDirPath: (p: string, base?: string) => string;Resolves a user-supplied path to an absolute form and validates it.
Always rejects paths containing null bytes or newlines (C-level argument injection risk even with array-form execFile).
When
baseis provided, also enforces containment: the resolved path must start with the resolvedbasedirectory. ThisstartsWith-based check is the pattern that CodeQL's path-injection analysis recognises as a sanitizer, clearing the taint on the returned value for interprocedural analysis.
function serializeToYaml
serializeToYaml: ( object: any, skipInvalid?: boolean, noRefs?: boolean) => string;function setPrinter
setPrinter: (value: (message: string) => void) => void;function spawn
spawn: ( command: string, args?: Array<string> | null, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions) => Promise<any>;function spawnAndWrite
spawnAndWrite: ( command: string, args: Array<string>, data: string, options?: SpawnOptions) => Promise<any>;function spawnAndWriteWithOutput
spawnAndWriteWithOutput: ( command: string, args: Array<string>, data: string, options?: SpawnOptions) => Promise<{ stdout: string; stderr: string }>;function statOrNull
statOrNull: (file: string) => Promise<Stats | null>;function stripSensitiveEnvVars
stripSensitiveEnvVars: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;Returns a copy of the environment with sensitive keys removed. Use this when building the environment for child processes that do not need signing credentials, tokens, or passwords (e.g. package managers).
function to7zaOutputSwitch
to7zaOutputSwitch: (p: string) => string;Validates a path and returns the complete 7-Zip
-o<dir>switch token.Input is first normalized via
sanitizeDirPath(absolute resolution + null/newline rejection), then validated for 7za switch-token safety.Allowlist rejects: - empty string (7za would receive bare
-o, which fails) - leading-(7za would misparse the token as a new switch) - control chars 0x00–0x1F and DEL 0x7F (C-level truncation/control risk)
function toLinuxArchString
toLinuxArchString: (arch: Arch, targetName: string) => string;function unlinkIfExists
unlinkIfExists: (file: string) => Promise<void>;function use
use: <T, R>(value: T | Nullish, task: (value: T) => R) => R | null;function USE_HARD_LINKS
USE_HARD_LINKS: (file: string) => boolean;function walk
walk: ( initialDirPath: string, filter?: Filter | null, consumer?: FileConsumer) => Promise<Array<string>>;Returns list of file paths (system-dependent file separator)
Classes
class AsyncTaskManager
class AsyncTaskManager {}constructor
constructor(cancellationToken: CancellationToken);property tasks
readonly tasks: Promise<any>[];method add
add: (task: () => Promise<any>) => void;method addTask
addTask: (promise: Promise<any>) => void;method awaitTasks
awaitTasks: () => Promise<Array<any>>;method cancelTasks
cancelTasks: () => void;class CopyFileTransformer
class CopyFileTransformer {}constructor
constructor(afterCopyTransformer: AfterCopyFileTransformer);property afterCopyTransformer
readonly afterCopyTransformer: AfterCopyFileTransformer;class DebugLogger
class DebugLogger {}constructor
constructor(isEnabled?: boolean);property data
readonly data: Map<string, any>;property isEnabled
readonly isEnabled: boolean;method add
add: (key: string, value: any) => void;method save
save: (file: string) => Promise<void>;class ExecError
class ExecError extends Error {}constructor
constructor( command: string, exitCode: number, out: string, errorOut: string, code?: string);property alreadyLogged
alreadyLogged: boolean;property code
static code: string;property exitCode
readonly exitCode: number;class FileCopier
class FileCopier {}constructor
constructor( isUseHardLinkFunction?: (file: string) => boolean, transformer?: FileTransformer);property isUseHardLink
isUseHardLink: boolean;method copy
copy: (src: string, dest: string, stat: Stats | undefined) => Promise<void>;class InvalidConfigurationError
class InvalidConfigurationError extends Error {}constructor
constructor(message: string, code?: string);class Logger
class Logger {}constructor
constructor(stream: WritableStream);property isDebugEnabled
readonly isDebugEnabled: boolean;property messageTransformer
messageTransformer: (message: string, level: LogLevel) => string;property stream
protected readonly stream: WritableStream;method createMessage
static createMessage: ( message: string, fields: Fields | null, level: LogLevel, color: (it: string) => string, messagePadding?: number) => string;method debug
debug: (fields: Fields | null, message: string) => void;method error
error: (messageOrFields: Fields | null | string, message?: string) => void;method filePath
filePath: (file: string) => string;method info
info: (messageOrFields: Fields | null | string, message?: string) => void;method log
log: (message: string) => void;method warn
warn: (messageOrFields: Fields | null | string, message?: string) => void;class NestedError
class NestedError extends Error {}constructor
constructor(errors: Error[], message?: string);class NodeHttpExecutor
class NodeHttpExecutor extends HttpExecutor<ClientRequest> {}method createRequest
createRequest: ( options: any, callback: (response: any) => void) => ClientRequest;Interfaces
interface CopyDirOptions
interface CopyDirOptions {}property filter
filter?: Filter | null;property isUseHardLink
isUseHardLink?: ((file: string) => boolean) | null;property transformer
transformer?: FileTransformer | null;interface ExtraSpawnOptions
interface ExtraSpawnOptions {}property isPipeInput
isPipeInput?: boolean;interface Fields
interface Fields {}index signature
[index: string]: any;interface FileConsumer
interface FileConsumer {}property isIncludeDir
isIncludeDir?: boolean;false
method consume
consume: ( file: string, fileStat: Stats, parent: string, siblingNames: Array<string>) => any;interface FilterStats
interface FilterStats extends Stats {}property linkRelativeToFile
linkRelativeToFile?: string;property moduleFullFilePath
moduleFullFilePath?: string;property moduleName
moduleName?: string;property moduleRootPath
moduleRootPath?: string;property relativeLink
relativeLink?: string;Enums
Type Aliases
type AfterCopyFileTransformer
type AfterCopyFileTransformer = (file: string) => Promise<boolean>;type ArchType
type ArchType = 'x64' | 'ia32' | 'armv7l' | 'arm64' | 'universal';type FileTransformer
type FileTransformer = ( file: string) => | Promise<null | string | Buffer | CopyFileTransformer> | null | string | Buffer | CopyFileTransformer;type Filter
type Filter = (file: string, stat: FilterStats) => boolean;type LogLevel
type LogLevel = 'info' | 'warn' | 'debug' | 'error';Package Files (12)
Dependencies (14)
Dev Dependencies (5)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/builder-util.
- Markdown[](https://www.jsdocs.io/package/builder-util)
- HTML<a href="https://www.jsdocs.io/package/builder-util"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3791 ms. - Missing or incorrect documentation? Open an issue for this package.
