npm.io
3.0.0 • Published 7 months agoCLI

@voltiso/script

Licence
MIT
Version
3.0.0
Deps
5
Size
119 kB
Vulns
1
Weekly
0
Stars
2

@voltiso/script

NPM scripts as code.

Use in YOUR project

pnpm add -D @voltiso/script

Define some scripts

Create scripts.ts files in your project directory, or any directory above it, e.g.:

// scripts.ts
import { parallel } from '@voltiso/script'

export const build = 'tsc -b'

export const lintBiome = 'biome lint'
export const lintTsc = 'tsc --noEmit'

export const lint = parallel(lintBiome, lintTsc)

export const check = [build, lint] // sequential

export const custom = async () => {
	console.log('custom script')
	return 'pnpm publish' // optional return
}

CLI Usage

pnpm exec v [command]

...or - longer version:

pnpm exec voltiso-script [command]

The script is searched for in this order:

  1. package.json scripts
  2. scripts.ts file in the current directory
  3. scripts.ts file in the parent directory, and so on

Even if the script is found in a directory above, the cwd does NOT change. This allows defining common scripts in a parent directory, instead of duplicating them in every project.