Registry / devops / suf-node

suf-node

JSON →
library1.3.3jsnpmunverified

suf-node is a lightweight collection of utility functions designed specifically for Node.js environments. It provides asynchronous, promise-based wrappers for common operations across console interaction, process execution, and file system management. Key functionalities include `readConsole` and `getYNAnswer` for interactive command-line interface (CLI) input, `Exec` for safely running shell commands, and `Walk` and `Exits` for directory traversal and path existence checks, respectively. Currently at version 1.3.3, this library maintains a focused release cadence, typically releasing new features or bug fixes as needed for its specific utility scope. Its primary differentiator is a simple, modern API built on Promises, making it well-suited for async/await patterns in contemporary Node.js applications, aiming to streamline common tasks without introducing heavy external dependencies. The project appears to be actively maintained, providing foundational utilities for Node.js projects.

npm install suf-node
INSTALL
IMPORT
SIG · SUF-NODE
S
suf-node
devopsjavascriptv1.3.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

readConsole
import { readConsole } from 'suf-node';
const { readConsole } = require('suf-node');
The library primarily uses ES Modules. While CommonJS `require` might work in some setups, direct ESM import is recommended for type safety and modern Node.js environments. Since suf-node 1.x ships with TypeScript definitions, ESM is the canonical import style.
Exec
import { Exec } from 'suf-node';
const Exec = require('suf-node').Exec;
Use named import for `Exec` function. The `Exec` function returns a Promise, so it must be `await`ed or chained with `.then()`.
Walk
import { Walk } from 'suf-node';
const Walk = require('suf-node').Walk;
`Walk` is a named export for file system traversal. Like other utilities in this library, it is asynchronous and returns a Promise.

Demonstrates interactive console input, executing shell commands, and listing files in a directory using the promise-based `readConsole`, `getYNAnswer`, `Exec`, and `Walk` functions.

import { Exec, Walk, readConsole, getYNAnswer } from 'suf-node'; import path from 'path'; async function main() { console.log('--- SUF Node Quickstart ---'); // Example 1: Read console input console.log('\nEnter your name:'); const name = await readConsole(); console.log(`Hello, ${name}!`); // Example 2: Get Y/N answer console.log('\nDo you like Node.js? (Y/n)'); const likesNode = await getYNAnswer(true); // Default to true console.log(likesNode ? 'Great!' : 'Oh well.'); // Example 3: Execute a shell command try { console.log('\nExecuting `ls -l` in current directory:'); const { stdout, stderr } = await Exec('ls -l', { linkStdout: false }); if (stdout) console.log('Stdout:\n' + stdout); if (stderr) console.error('Stderr:\n' + stderr); } catch (error) { console.error('Exec failed:', error); } // Example 4: Walk a directory try { console.log('\nWalking current directory:'); const files = await Walk(process.cwd()); console.log('Files found:', files.slice(0, 5).map(f => path.basename(f)).join(', ') + (files.length > 5 ? '...' : '')); } catch (error) { console.error('Walk failed:', error); } console.log('\n--- Quickstart complete ---'); } main().catch(console.error);
Debug
Known issues
gotchaAll utility functions in `suf-node` are asynchronous and return Promises. Forgetting to use `await` or `.then()` will result in Promises not being resolved, leading to unexpected behavior or unhandled promise rejections.
fix
Always `await` calls to `suf-node` functions, or handle the returned Promise with `.then().catch()`.
affects: >=1.0.0
breakingThe library is primarily designed for ES Modules (ESM). Older Node.js projects using CommonJS (`require`) might encounter issues with default or named exports if their `package.json` `type` field is not set to `module`, or if they are running an older Node.js version.
fix
Ensure your Node.js project is configured for ESM (e.g., `"type": "module"` in `package.json`) or use a transpiler like Babel/TypeScript to convert to CommonJS if necessary. Explicitly import named exports: `import { funcName } from 'suf-node';`.
affects: >=1.0.0
gotchaThe `Exec` function runs arbitrary shell commands. Directly passing untrusted user input to `Exec` can lead to command injection vulnerabilities, allowing attackers to execute arbitrary code on your system.
fix
Sanitize all user-provided input before passing it to `Exec`. Consider using Node.js's built-in `child_process.execFile` or `child_process.spawn` for better control and security when executing commands from external input, or use a command-line argument parsing library if user input specifies options.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0, suf_node_1.readConsole) is not a function
This typically occurs when attempting to use CommonJS `require` syntax or incorrect named imports in an ES Module context, or vice-versa, causing the module resolution to fail.
fix
Ensure you are using `import { readConsole } from 'suf-node';` in an ES Module environment (`"type": "module"` in `package.json`), or adjust your bundler configuration if applicable.
UnhandledPromiseRejectionWarning: Unhandled promise rejection.
An asynchronous `suf-node` function (e.g., `Exec`, `Walk`, `readConsole`) returned a Promise that rejected, but the rejection was not caught by a `.catch()` block or an `await` within a `try...catch` statement.
fix
Wrap asynchronous calls in `try...catch` blocks when using `await`, or append a `.catch(error => console.error(error))` to your Promise chains.
Error: Command failed: <your_command_here>
The `Exec` function's underlying shell command exited with a non-zero status code, indicating an error during its execution (e.g., command not found, permission denied, syntax error in the command).
fix
Inspect the error message from the `Exec` rejection to understand the specific command failure. Check the command's syntax, ensure necessary executables are in the system's PATH, and verify file/directory permissions if applicable.
Upgrade
Version history
1.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
suf-node — npm install suf-node · libregistry