@@ -95,6 +95,12 @@ const yarnInstallLikeCommands = new Set([
9595 *
9696 * SECURITY: Uses array-based arguments to prevent command injection. All elements
9797 * in the args array are properly escaped by Node.js when passed to spawn().
98+ *
99+ * @example
100+ * ```typescript
101+ * await execNpm(['install', '--save', 'lodash'])
102+ * await execNpm(['run', 'build'], { cwd: '/tmp/project' })
103+ * ```
98104 */
99105export function execNpm ( args : string [ ] , options ?: SpawnOptions | undefined ) {
100106 const useDebug = isDebug ( )
@@ -157,6 +163,12 @@ export interface PnpmOptions extends SpawnOptions {
157163 *
158164 * SECURITY: Uses array-based arguments to prevent command injection. All elements
159165 * in the args array are properly escaped by Node.js when passed to execBin().
166+ *
167+ * @example
168+ * ```typescript
169+ * await execPnpm(['install'])
170+ * await execPnpm(['add', 'lodash'], { allowLockfileUpdate: true })
171+ * ```
160172 */
161173export function execPnpm ( args : string [ ] , options ?: PnpmOptions | undefined ) {
162174 const { allowLockfileUpdate, ...extBinOpts } = {
@@ -224,6 +236,12 @@ export function execPnpm(args: string[], options?: PnpmOptions | undefined) {
224236 *
225237 * SECURITY: Uses array-based arguments to prevent command injection. All elements
226238 * in the args array are properly escaped by Node.js when passed to execBin().
239+ *
240+ * @example
241+ * ```typescript
242+ * await execYarn(['install'])
243+ * await execYarn(['add', 'lodash'], { cwd: '/tmp/project' })
244+ * ```
227245 */
228246export function execYarn (
229247 args : string [ ] ,
@@ -271,6 +289,13 @@ export function execYarn(
271289
272290/**
273291 * Check if a command argument is an npm audit flag.
292+ *
293+ * @example
294+ * ```typescript
295+ * isNpmAuditFlag('--no-audit') // true
296+ * isNpmAuditFlag('--audit') // true
297+ * isNpmAuditFlag('--save') // false
298+ * ```
274299 */
275300/*@__NO_SIDE_EFFECTS__ */
276301export function isNpmAuditFlag ( cmdArg : string ) : boolean {
@@ -279,6 +304,13 @@ export function isNpmAuditFlag(cmdArg: string): boolean {
279304
280305/**
281306 * Check if a command argument is an npm fund flag.
307+ *
308+ * @example
309+ * ```typescript
310+ * isNpmFundFlag('--no-fund') // true
311+ * isNpmFundFlag('--fund') // true
312+ * isNpmFundFlag('--save') // false
313+ * ```
282314 */
283315/*@__NO_SIDE_EFFECTS__ */
284316export function isNpmFundFlag ( cmdArg : string ) : boolean {
@@ -287,6 +319,14 @@ export function isNpmFundFlag(cmdArg: string): boolean {
287319
288320/**
289321 * Check if a command argument is an npm loglevel flag.
322+ *
323+ * @example
324+ * ```typescript
325+ * isNpmLoglevelFlag('--loglevel') // true
326+ * isNpmLoglevelFlag('--silent') // true
327+ * isNpmLoglevelFlag('-s') // true
328+ * isNpmLoglevelFlag('--save') // false
329+ * ```
290330 */
291331/*@__NO_SIDE_EFFECTS__ */
292332export function isNpmLoglevelFlag ( cmdArg : string ) : boolean {
@@ -304,6 +344,13 @@ export function isNpmLoglevelFlag(cmdArg: string): boolean {
304344
305345/**
306346 * Check if a command argument is an npm node-options flag.
347+ *
348+ * @example
349+ * ```typescript
350+ * isNpmNodeOptionsFlag('--node-options') // true
351+ * isNpmNodeOptionsFlag('--node-options=--max-old-space-size=4096') // true
352+ * isNpmNodeOptionsFlag('--save') // false
353+ * ```
307354 */
308355/*@__NO_SIDE_EFFECTS__ */
309356export function isNpmNodeOptionsFlag ( cmdArg : string ) : boolean {
@@ -313,6 +360,13 @@ export function isNpmNodeOptionsFlag(cmdArg: string): boolean {
313360
314361/**
315362 * Check if a command argument is an npm progress flag.
363+ *
364+ * @example
365+ * ```typescript
366+ * isNpmProgressFlag('--no-progress') // true
367+ * isNpmProgressFlag('--progress') // true
368+ * isNpmProgressFlag('--save') // false
369+ * ```
316370 */
317371/*@__NO_SIDE_EFFECTS__ */
318372export function isNpmProgressFlag ( cmdArg : string ) : boolean {
@@ -321,6 +375,13 @@ export function isNpmProgressFlag(cmdArg: string): boolean {
321375
322376/**
323377 * Check if a command argument is a pnpm ignore-scripts flag.
378+ *
379+ * @example
380+ * ```typescript
381+ * isPnpmIgnoreScriptsFlag('--ignore-scripts') // true
382+ * isPnpmIgnoreScriptsFlag('--no-ignore-scripts') // true
383+ * isPnpmIgnoreScriptsFlag('--save') // false
384+ * ```
324385 */
325386/*@__NO_SIDE_EFFECTS__ */
326387export function isPnpmIgnoreScriptsFlag ( cmdArg : string ) : boolean {
@@ -329,6 +390,13 @@ export function isPnpmIgnoreScriptsFlag(cmdArg: string): boolean {
329390
330391/**
331392 * Check if a command argument is a pnpm frozen-lockfile flag.
393+ *
394+ * @example
395+ * ```typescript
396+ * isPnpmFrozenLockfileFlag('--frozen-lockfile') // true
397+ * isPnpmFrozenLockfileFlag('--no-frozen-lockfile') // true
398+ * isPnpmFrozenLockfileFlag('--save') // false
399+ * ```
332400 */
333401/*@__NO_SIDE_EFFECTS__ */
334402export function isPnpmFrozenLockfileFlag ( cmdArg : string ) : boolean {
@@ -337,6 +405,13 @@ export function isPnpmFrozenLockfileFlag(cmdArg: string): boolean {
337405
338406/**
339407 * Check if a command argument is a pnpm install command.
408+ *
409+ * @example
410+ * ```typescript
411+ * isPnpmInstallCommand('install') // true
412+ * isPnpmInstallCommand('i') // true
413+ * isPnpmInstallCommand('run') // false
414+ * ```
340415 */
341416/*@__NO_SIDE_EFFECTS__ */
342417export function isPnpmInstallCommand ( cmdArg : string ) : boolean {
@@ -351,6 +426,12 @@ export const isPnpmLoglevelFlag = isNpmLoglevelFlag
351426/**
352427 * Execute a package.json script using the appropriate package manager.
353428 * Automatically detects pnpm, yarn, or npm based on lockfiles.
429+ *
430+ * @example
431+ * ```typescript
432+ * await execScript('build')
433+ * await execScript('test', ['--coverage'], { cwd: '/tmp/project' })
434+ * ```
354435 */
355436export interface ExecScriptOptions extends SpawnOptions {
356437 prepost ?: boolean | undefined
0 commit comments