@rondymesquita/nutshell v0.23.0
Nutshell
Write better shell scripts using NodeJS
Create a example.js
#!/usr/bin/env nutshell
;(async () => {
run`echo "Hello"`
run`
echo "Multiline commands"
echo "using template literals"
`
await withContext(() => {
run`
echo "I am running"
echo "in a separated process"
`
})
})()Run:
./example.jsRequire
const {
ls,
run,
withContext,
} = require('@rondymesquita/nutshell')
;(async () => {
run`echo "Hello"`
await withContext(() => {
ls()
})
})()Run:
node example.jsUsing Typescript
For usage with Typescript, change intepreter to any typescript interpreter like tsx or ts-node.
https://github.com/esbuild-kit/tsx https://www.npmjs.com/package/ts-node
#!/usr/bin/env tsx
// import to enable type checking
import '@rondymesquita/nutshell/src/globals'
;(async () => {
run`echo "Hello"`
run`
echo "Multiline commands"
echo "using template literals"
`
await withContext(() => {
run`
echo "I am running"
echo "in a separated process"
`
})
})()./example.tsImport
import { ls, run, withContext } from '@rondymesquita/nutshell'
;(async () => {
run`echo "Hello"`
await withContext(() => {
ls()
})
})()Run:
tsx example.tsUsing with tasks
const unit = async() => {
run`echo "Hello"`
run`
echo "Multiline commands"
echo "using template literals"
`
await withContext(async() => {
run`
echo "I am running"
echo "in a separated process"
`
})
ls()
}
tasks({ unit, })$ node file.js unitConfiguration
Set custom configuration with setConfig
TBD
Configuration options
TBD
API
TBD
Motivation
Sometimes, writing shell scripts can be challenging, specially when we need to do conditionals, loops, reading files like JSON or YAML. Nutshell helps in these cases leveraging the knowledge in Javascript without being too far of Shell Scripts.
Logo By icons8
Inspired by Google zx, but using libraries I personaly prefer.
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago