{"id":15650719,"url":"https://github.com/jonschlinkert/fs-utils","last_synced_at":"2025-04-30T18:09:20.908Z","repository":{"id":13195956,"uuid":"15879668","full_name":"jonschlinkert/fs-utils","owner":"jonschlinkert","description":"Generalized file and path utils for Node.js projects.","archived":false,"fork":false,"pushed_at":"2020-04-01T00:04:19.000Z","size":113,"stargazers_count":35,"open_issues_count":3,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-30T18:09:13.913Z","etag":null,"topics":["copy","file","file-system","fs","read","write"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jonschlinkert.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":"2014-01-13T19:49:15.000Z","updated_at":"2025-03-08T15:52:05.000Z","dependencies_parsed_at":"2022-09-01T06:41:28.755Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/fs-utils","commit_stats":null,"previous_names":["assemble/fs-utils"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffs-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffs-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffs-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffs-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/fs-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758170,"owners_count":21638989,"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":["copy","file","file-system","fs","read","write"],"created_at":"2024-10-03T12:35:37.133Z","updated_at":"2025-04-30T18:09:20.884Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fs-utils [![NPM version](https://badge.fury.io/js/fs-utils.svg)](http://badge.fury.io/js/fs-utils)\n\n\u003e fs extras and utilities to extend the node.js file system module. Used in Assemble and many other projects.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i fs-utils --save\n```\n\n## Usage\n\n```js\nvar fs = require('fs-utils');\n```\n\n## API\n\n### [.stripCR](index.js#L24)\n\nStrip carriage returns from a string.\n\n**Params**\n\n* `str` **{String}**\n* `returns` **{String}**\n\n### [.stripBOM](index.js#L38)\n\nStrip byte order marks from a string.\n\nSee [BOM](http://en.wikipedia.org/wiki/Byte_order_mark)\n\n**Params**\n\n* `str` **{String}**\n* `returns` **{String}**\n\n### [.slashify](index.js#L51)\n\nNormalize all slashes to forward slashes.\n\n**Params**\n\n* `str` **{String}**\n* `stripTrailing` **{Boolean}**: False by default.\n* `returns` **{String}**\n\n### [.isEmptyFile](index.js#L94)\n\nReturn `true` if the file exists and is empty.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Boolean}**\n\n### [.isEmptyDir](index.js#L110)\n\nReturn `true` if the file exists and is empty.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Boolean}**\n\n### [.isDir](index.js#L126)\n\nReturn `true` if the filepath is a directory.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Boolean}**\n\n### [.isLink](index.js#L157)\n\nTrue if the filepath is a symbolic link.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Boolean}**\n\n### [.glob](index.js#L171)\n\nGlob files using [matched]. Or glob files synchronously\nwith `glob.sync`.\n\n**Params**\n\n* `patterns` **{String|Array}**\n* `returns` **{options}**\n\n### [.readFileSync](index.js#L182)\n\nRead a file synchronously. Also strips any byte order\nmarks.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [readFile](index.js#L202)\n\nRead a file asynchronously.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**\n* `normalize` **{Boolean}**: Strip carriage returns and BOM.\n* `encoding` **{String}**: Default is `utf8`\n* `callback` **{Function}**\n\n### [.readYAML](index.js#L233)\n\nRead a YAML file asynchronously and parse its contents as JSON.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Object}** `options`\n* `returns` **{Function}** `cb`: Callback function\n\n### [.readYAMLSync](index.js#L245)\n\nRead a YAML file synchronously and parse its contents as JSON\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Object}**\n\n### [.readJSON](index.js#L258)\n\nRead JSON file asynchronously and parse contents as JSON\n\n**Params**\n\n* `filepath` **{String}**\n* `callback` **{Function}**\n* `returns` **{Object}**\n\n### [.readJSONSync](index.js#L275)\n\nRead a file synchronously and parse contents as JSON.\nmarks.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Object}**\n\n### [.readData](index.js#L290)\n\nRead JSON or YAML utils.async. Determins the reader automatically\nbased on file extension.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**\n* `callback` **{Function}**\n* `returns` **{String}**\n\n### [.readDataSync](index.js#L304)\n\nRead JSON or utils.YAML. Determins the reader automatically\nbased on file extension.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**\n* `returns` **{String}**\n\n### [.writeFile](index.js#L358)\n\nAsynchronously write a file to disk.\n\n**Params**\n\n* `dest` **{String}**\n* `content` **{String}**\n* `callback` **{Function}**\n\n### [.writeFileSync](index.js#L372)\n\nSynchronously write files to disk, creating any\nintermediary directories if they don't exist.\n\n**Params**\n\n* `dest` **{String}**\n* `str` **{String}**\n* `options` **{Options}**\n\n### [.writeJSONSync](index.js#L386)\n\nSynchronously write JSON to disk, creating any\nintermediary directories if they don't exist.\n\n**Params**\n\n* `dest` **{String}**\n* `str` **{String}**\n* `options` **{Options}**\n\n### [.writeJSON](index.js#L400)\n\nAsynchronously write files to disk, creating any\nintermediary directories if they don't exist.\n\n**Params**\n\n* `dest` **{String}**\n* `str` **{String}**\n* `options` **{Options}**\n\n### [.writeYAMLSync](index.js#L414)\n\nSynchronously write YAML to disk, creating any\nintermediary directories if they don't exist.\n\n**Params**\n\n* `dest` **{String}**\n* `str` **{String}**\n* `options` **{Options}**\n\n### [.writeYAML](index.js#L428)\n\nAynchronously write YAML to disk, creating any\nintermediary directories if they don't exist.\n\n**Params**\n\n* `dest` **{String}**\n* `str` **{String}**\n* `options` **{Options}**\n\n### [.writeDataSync](index.js#L447)\n\nSynchronously write JSON or YAML to disk, creating any intermediary directories if they don't exist. Data type is determined by the `dest` file extension.\n\n**Params**\n\n* `dest` **{String}**\n* `str` **{String}**\n* `options` **{Options}**\n\n**Example**\n\n```js\nwriteDataSync('foo.yml', {foo: \"bar\"});\n```\n\n### [.writeData](index.js#L467)\n\nAsynchronously write JSON or YAML to disk, creating any intermediary directories if they don't exist. Data type is determined by the `dest` file extension.\n\n**Params**\n\n* `dest` **{String}**\n* `data` **{String}**\n* `options` **{Options}**\n* `cb` **{Function}**: Callback function\n\n**Example**\n\n```js\nwriteData('foo.yml', {foo: \"bar\"});\n```\n\n### [.copyFileSync](index.js#L479)\n\nCopy files synchronously;\n\n**Params**\n\n* `src` **{String}**\n* `dest` **{String}**\n\n### [.rmdir](index.js#L492)\n\nAsynchronously remove dirs and child dirs that exist.\n\n**Params**\n\n* `dir` **{String}**\n* **{Function}**: `cb\n* `returns` **{Function}**\n\n### [.del](index.js#L529)\n\nDelete folders and files recursively. Pass a callback\nas the last argument to use utils.async.\n\n**Params**\n\n* `patterns` **{String}**: Glob patterns to use.\n* `options` **{Object}**: Options for matched.\n* `cb` **{Function}**\n\n### [.ext](index.js#L597)\n\nReturn the file extension.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.dirname](index.js#L609)\n\nDirectory path excluding filename.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.last](index.js#L635)\n\nThe last `n` segments of a filepath. If a number\nisn't passed for `n`, the last segment is returned.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.first](index.js#L650)\n\nThe first `n` segments of a filepath. If a number\nisn't passed for `n`, the first segment is returned.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.lastChar](index.js#L669)\n\nReturns the last character in `filepath`\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n**Example**\n\n```\nlastChar('foo/bar/baz/');\n//=\u003e '/'\n```\n\n### [.addSlash](index.js#L696)\n\nAdd a trailing slash to the filepath.\n\nNote, this does _not_ consult the file system\nto check if the filepath is file or a directory.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.normalizePath](index.js#L711)\n\nNormalize a filepath and remove trailing slashes.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.relative](index.js#L737)\n\nResolve the relative path from `a` to `b.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{String}**\n\n### [.isAbsolute](index.js#L749)\n\nReturn `true` if the path is absolute.\n\n**Params**\n\n* **{[type]}**: filepath\n* `returns` **{Boolean}**\n\n### [.equivalent](index.js#L763)\n\nReturn `true` if path `a` is the same as path `b.\n\n**Params**\n\n* `filepath` **{String}**\n* `a` **{String}**\n* `b` **{String}**\n* `returns` **{Boolean}**\n\n### [.doesPathContain](index.js#L778)\n\nTrue if descendant path(s) contained within ancestor path. Note: does not test if paths actually exist.\n\nSourced from [Grunt].\n\n**Params**\n\n* `ancestor` **{String}**: The starting path.\n* `returns` **{Boolean}**\n\n### [.isPathCwd](index.js#L807)\n\nTrue if a filepath is the CWD.\n\nSourced from [Grunt].\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Boolean}**\n\n### [.isPathInCwd](index.js#L824)\n\nTrue if a filepath is contained within the CWD.\n\n**Params**\n\n* `filepath` **{String}**\n* `returns` **{Boolean}**\n\n## Related projects\n\n* [read-data](https://www.npmjs.com/package/read-data): Read JSON or YAML files. | [homepage](https://github.com/jonschlinkert/read-data)\n* [read-yaml](https://www.npmjs.com/package/read-yaml): Very thin wrapper around js-yaml for directly reading in YAML files. | [homepage](https://github.com/jonschlinkert/read-yaml)\n* [write-data](https://www.npmjs.com/package/write-data): Write a YAML or JSON file to disk. Automatically detects the format to write based… [more](https://www.npmjs.com/package/write-data) | [homepage](https://github.com/jonschlinkert/write-data)\n* [write-json](https://www.npmjs.com/package/write-json): Write a JSON file to disk, also creates intermediate directories in the destination path if… [more](https://www.npmjs.com/package/write-json) | [homepage](https://github.com/jonschlinkert/write-json)\n* [write-yaml](https://www.npmjs.com/package/write-yaml): Write YAML. Converts JSON to YAML writes it to the specified file. | [homepage](https://github.com/jonschlinkert/write-yaml)\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d \u0026\u0026 npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/assemble/fs-utils/issues/new).\n\n## Author\n\n**Jon Schlinkert**\n\n+ [github/assemble](https://github.com/assemble)\n+ [twitter/assemble](http://twitter.com/assemble)\n\n## License\n\nCopyright © 2015 Jon Schlinkert\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 17, 2015._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Ffs-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Ffs-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Ffs-utils/lists"}