{"id":15493470,"url":"https://github.com/sinclairzx81/smoke-task","last_synced_at":"2026-03-09T18:36:28.308Z","repository":{"id":57364230,"uuid":"169084154","full_name":"sinclairzx81/smoke-task","owner":"sinclairzx81","description":"Runs JavaScript functions from a terminal","archived":false,"fork":false,"pushed_at":"2020-12-02T23:27:27.000Z","size":71,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T19:57:32.119Z","etag":null,"topics":["automation","node","npm-scripts","tasks"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinclairzx81.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-04T13:41:27.000Z","updated_at":"2021-11-27T04:39:30.000Z","dependencies_parsed_at":"2022-08-29T13:40:32.667Z","dependency_job_id":null,"html_url":"https://github.com/sinclairzx81/smoke-task","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sinclairzx81/smoke-task","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsmoke-task","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsmoke-task/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsmoke-task/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsmoke-task/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/smoke-task/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsmoke-task/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266210843,"owners_count":23893338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","node","npm-scripts","tasks"],"created_at":"2024-10-02T08:06:59.163Z","updated_at":"2026-03-09T18:36:23.217Z","avatar_url":"https://github.com/sinclairzx81.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smoke-Task\n\nA JavaScript task runner for node.\n\n[![NPM package](https://badge.fury.io/js/smoke-task.svg)](https://www.npmjs.com/package/smoke-task)\n\n```\n$ npm install smoke-task --save-dev\n```\n```javascript\nexport async function add(a, b) {\n  await shell(`echo ${a + b}`).exec()\n}\n```\n```bash\n$ npx smoke-task add 10 20\n# $ echo 30\n# 30\n```\n\n## Overview\n\nSmoke-Task is a shell scripting tool that allows javascript functions to be exposed and run from a terminal. It is intended to be a lightweight single dependency cli module to assist with various build tasks for node projects.\n\nThis tool is offered for anyone who finds it useful. Supports node 10 and up.\n\n## Tasks\n\nSmoke-Task requires that a `tasks.js` file exist in the current working directory (typically a project root). For a tasks to be available to the task runner, the functions must be exported.\n\n```typescript\n/** A task to build a TypeScript project, then run the project */\nexport async function start() {\n  await shell('tsc --project ./src/tsconfig.json').exec()\n  await shell('node ./src/index.js').exec()\n}\n```\n```\n$ smoke-task start\n```\n\n## Functions\n\nTasks defined within `tasks.js` have access to four global functions that allow for various folder, file, shell and watch operations to be composed within each task. The API for these functions is outlined below.\n\n```typescript\nshell(command)\n    .err(func)            // Redirects stderr data to the given function.\n    .exec()               // (eval) Executes this shell command.\n    .expect(exitcode)     // Sets the expected exitcode for this command. Default is 0.\n    .log(func)            // Redirects both stdout and stderr to the given function.\n    .out(func)            // Redirects stdout data to the given function.\n\nwatch(path)\n    .timeout(ms)          // Sets a this watchers debounce timeout (default is 250ms)\n    .run(func)            // Runs this function when a file or folder changes.\n    .exec()               // Executes this watch (does not complete)\n\nfolder(path)\n    .add(path)            // Adds a file to this folder. If the path being added exists, it is overwritten.\n    .copy_to(folder)      // Copies this folder into the given folder.\n    .contents()           // Returns the inner contents of this folder (see contents)\n        .copy_to(folder)  // Copies the contents into the given folder.\n        .move_to(folder)  // Moves the contents into the given folder.\n        .delete()         // Deletes the contents of this folder.\n        .exec()           // Executes effects on these contents.\n    .create()             // Creates this folder if not exists.\n    .delete()             // Deletes this folder if exists.\n    .exec()               // (eval) Executes effects on this folder.\n    .exists()             // (eval) Returns true if this folder exists.\n    .hash(algo?)          // (eval) Returns a hash of this folder with the given algorithm.\n    .merge_from(folder)   // Merges the contents from the remote folder into this folder.\n    .move_to(folder)      // Moves this folder into the given folder.\n    .remove(name)         // Removes a file or folder from this folder.\n    .rename(newname)      // Renames this folder.\n    .size()               // (eval) Returns the size of this folder in bytes.\n    .stat()               // (eval) Returns a fs stats object for this folder.\n\nfile(path)\n    .append_from(path)    // Appends to this file from a remote path | url. If file not exist, create.\n    .append(data)         // Appends to this file. If file not exist, create.\n    .copy_to(folder)      // Copies this file into the given folder. \n    .create()             // Creates this file if not exists.\n    .delete()             // Deletes this file if exists.\n    .edit(find, replace)  // Makes a find and replace edit to this file.\n    .exec()               // (eval) Executes effects on this file.\n    .exists()             // (eval) Returns true if this file exists.\n    .hash(algo?)          // (eval) Returns a hash for this file with the given algorithm.\n    .move_to(folder)      // Moves this file into the given folder.\n    .prepend_from(path)   // Prepends to this file from a remote path | url. If file not exist, create.\n    .prepend(data)        // Prepends to this file. If file not exist, create.\n    .read(encoding?)      // (eval) Returns the contents of this file.\n    .rename(newname)      // Renames this file.\n    .size()               // (eval) Returns the size of this file in bytes.\n    .stat()               // (eval) Returns a fs stats object for this file.\n    .truncate()           // Truncates this file. If the file does not exist, it is created.\n    .write_from(path)     // Writes to this file from a remote path | url. If file not exist, create.\n    .write(data)          // Writes to this file. If the file does not exist, it is created.\n```\n\n\n\n\n## Project Tasks\n\nThe following tasks are supported.\n```bash\nnpm run clean       # cleans this project.\nnpm run build       # builds this project.\nnpm run spec        # runs the spec project in watch.\nnpm run pack        # builds a deployment package.\nnpm run install-cli # installs this package globally.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fsmoke-task","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Fsmoke-task","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fsmoke-task/lists"}