{"id":15493459,"url":"https://github.com/sinclairzx81/fs-effects","last_synced_at":"2025-04-22T19:47:54.868Z","repository":{"id":35069252,"uuid":"203056301","full_name":"sinclairzx81/fs-effects","owner":"sinclairzx81","description":"A library for composing various file, folder, shell and watch operations in node.","archived":false,"fork":false,"pushed_at":"2023-03-03T05:32:40.000Z","size":72,"stargazers_count":11,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T11:12:11.322Z","etag":null,"topics":["automation","file","folder","shell","watch"],"latest_commit_sha":null,"homepage":null,"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-18T21:03:02.000Z","updated_at":"2024-10-03T05:11:20.000Z","dependencies_parsed_at":"2025-03-04T07:31:51.658Z","dependency_job_id":null,"html_url":"https://github.com/sinclairzx81/fs-effects","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Ffs-effects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Ffs-effects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Ffs-effects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Ffs-effects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/fs-effects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250312369,"owners_count":21410022,"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","file","folder","shell","watch"],"created_at":"2024-10-02T08:06:49.861Z","updated_at":"2025-04-22T19:47:54.844Z","avatar_url":"https://github.com/sinclairzx81.png","language":"TypeScript","readme":"# fs-effects\n\nA library for composing various file, folder, shell and watch operations in node.\n\n[![NPM package](https://badge.fury.io/js/fs-effects.svg)](https://www.npmjs.com/package/fs-effects)  [![Build Status](https://travis-ci.org/sinclairzx81/fs-effects.svg?branch=master)](https://travis-ci.org/sinclairzx81/fs-effects)\n\n```bash\n$ npm install fs-effects --save\n```\n\n### Example\n\n```typescript\nimport { file, folder } from 'fs-effects'\n\n// creates 'foo.txt' and writes the string 'hello world'.\nawait file('foo.txt')\n    .write('hello world')\n    .exec()\n\n// creates file 'google.html' and writes content from remote url.\nawait file('google.html')\n    .write_from('http://google.com')\n    .exec()\n\n// creates a 'dist' folder and merges content from a 'bin' folder\n// folder and adds a license and readme.\nawait folder('dist')\n    .merge_from('bin')\n    .add('license')\n    .add('readme.md')\n    .exec()\n```\n\n### Reference\n\nThe following outlines the fs-effects surface api for `shell`, `watch`, `folder`, `file`. For a more comprehensive description of these functions, refer to the typescript definitions provided with this package. For general example usage, see the `tasks.js` file located in this project root.\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## Project Tasks\n\nThe following npm tasks are supported by this project.\n\n```bash\nnpm run clean       # cleans this project.\nnpm run start       # starts this project in watch mode.\nnpm run test        # runs tests for this project.\nnpm run pack        # packages this project.\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Ffs-effects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Ffs-effects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Ffs-effects/lists"}