All Projects → jonschlinkert → fs-utils

jonschlinkert / fs-utils

Licence: MIT License
Generalized file and path utils for Node.js projects.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fs-utils

write-yaml
Basic node.js utility for converting JSON to YAML and writing formatting YAML files to disk.
Stars: ✭ 38 (+15.15%)
Mutual labels:  fs, file, file-system, write
Write
Write data to the file system, creating any intermediate directories if they don't already exist. Used by flat-cache and many others!
Stars: ✭ 68 (+106.06%)
Mutual labels:  fs, file, file-system
python-yamlable
A thin wrapper of PyYaml to convert Python objects to YAML and back
Stars: ✭ 28 (-15.15%)
Mutual labels:  read, file, write
copy
Copy files using glob patterns. Sync, async, promise or streams. (node.js utility)
Stars: ✭ 84 (+154.55%)
Mutual labels:  copy, fs, write
readdir
Recursively read a directory, blazing fast. Use with picomatch or micromatch to match globs.
Stars: ✭ 37 (+12.12%)
Mutual labels:  fs, read, file-system
PCF8591 library
Library to use i2c analog IC with arduino and esp8266. Can read analog value and write analog value with only 2 wire (perfect for ESP-01).
Stars: ✭ 24 (-27.27%)
Mutual labels:  read, write
prsdigg
Build your value net on Web3 with Quill
Stars: ✭ 60 (+81.82%)
Mutual labels:  read, write
GraphIO.jl
Graph IO functionality for various formats.
Stars: ✭ 54 (+63.64%)
Mutual labels:  read, write
spark-hadoopoffice-ds
A Spark datasource for the HadoopOffice library
Stars: ✭ 36 (+9.09%)
Mutual labels:  read, write
Rollup Plugin Copy
Copy files and folders using Rollup
Stars: ✭ 128 (+287.88%)
Mutual labels:  copy, file
Poseidon
stealthy UM <-> KM communication system without creating any system threads, permanent hooks, driver objects, section objects or device objects.
Stars: ✭ 189 (+472.73%)
Mutual labels:  read, write
vue-fs
A Vue file management client, complete with a node/express/FS backend.
Stars: ✭ 40 (+21.21%)
Mutual labels:  fs, file-system
colocat
Fegeya Colocat, Colorized 'cat' implementation. Written in C++17.
Stars: ✭ 14 (-57.58%)
Mutual labels:  read, file
matched
Glob matching with support for multiple patterns and negation. Use `~` in cwd to find files in user home, or `@` for global npm modules.
Stars: ✭ 25 (-24.24%)
Mutual labels:  fs, file-system
Copy Webpack Plugin
Copy files and directories with webpack
Stars: ✭ 2,679 (+8018.18%)
Mutual labels:  copy, file
atomically
Write files atomically and reliably.
Stars: ✭ 136 (+312.12%)
Mutual labels:  file, write
watcher
The file system watcher that strives for perfection, with no native dependencies and optional rename detection support.
Stars: ✭ 37 (+12.12%)
Mutual labels:  fs, file
bash-glob
Bash-powered globbing for node.js. Alternative to node-glob. Does not work on Windows 9 and lower.
Stars: ✭ 13 (-60.61%)
Mutual labels:  fs, file-system
Cpx
A cli tool to watch and copy file globs.
Stars: ✭ 394 (+1093.94%)
Mutual labels:  copy, file
Fcfilemanager
iOS File Manager on top of NSFileManager for simplifying files management. 📂
Stars: ✭ 862 (+2512.12%)
Mutual labels:  copy, file

fs-utils NPM version

fs extras and utilities to extend the node.js file system module. Used in Assemble and many other projects.

Install

Install with npm

$ npm i fs-utils --save

Usage

var fs = require('fs-utils');

API

.stripCR

Strip carriage returns from a string.

Params

  • str {String}
  • returns {String}

.stripBOM

Strip byte order marks from a string.

See BOM

Params

  • str {String}
  • returns {String}

.slashify

Normalize all slashes to forward slashes.

Params

  • str {String}
  • stripTrailing {Boolean}: False by default.
  • returns {String}

.isEmptyFile

Return true if the file exists and is empty.

Params

  • filepath {String}
  • returns {Boolean}

.isEmptyDir

Return true if the file exists and is empty.

Params

  • filepath {String}
  • returns {Boolean}

.isDir

Return true if the filepath is a directory.

Params

  • filepath {String}
  • returns {Boolean}

.isLink

True if the filepath is a symbolic link.

Params

  • filepath {String}
  • returns {Boolean}

.glob

Glob files using [matched]. Or glob files synchronously with glob.sync.

Params

  • patterns {String|Array}
  • returns {options}

.readFileSync

Read a file synchronously. Also strips any byte order marks.

Params

  • filepath {String}
  • returns {String}

readFile

Read a file asynchronously.

Params

  • filepath {String}
  • options {Object}
  • normalize {Boolean}: Strip carriage returns and BOM.
  • encoding {String}: Default is utf8
  • callback {Function}

.readYAML

Read a YAML file asynchronously and parse its contents as JSON.

Params

  • filepath {String}
  • returns {Object} options
  • returns {Function} cb: Callback function

.readYAMLSync

Read a YAML file synchronously and parse its contents as JSON

Params

  • filepath {String}
  • returns {Object}

.readJSON

Read JSON file asynchronously and parse contents as JSON

Params

  • filepath {String}
  • callback {Function}
  • returns {Object}

.readJSONSync

Read a file synchronously and parse contents as JSON. marks.

Params

  • filepath {String}
  • returns {Object}

.readData

Read JSON or YAML utils.async. Determins the reader automatically based on file extension.

Params

  • filepath {String}
  • options {Object}
  • callback {Function}
  • returns {String}

.readDataSync

Read JSON or utils.YAML. Determins the reader automatically based on file extension.

Params

  • filepath {String}
  • options {Object}
  • returns {String}

.writeFile

Asynchronously write a file to disk.

Params

  • dest {String}
  • content {String}
  • callback {Function}

.writeFileSync

Synchronously write files to disk, creating any intermediary directories if they don't exist.

Params

  • dest {String}
  • str {String}
  • options {Options}

.writeJSONSync

Synchronously write JSON to disk, creating any intermediary directories if they don't exist.

Params

  • dest {String}
  • str {String}
  • options {Options}

.writeJSON

Asynchronously write files to disk, creating any intermediary directories if they don't exist.

Params

  • dest {String}
  • str {String}
  • options {Options}

.writeYAMLSync

Synchronously write YAML to disk, creating any intermediary directories if they don't exist.

Params

  • dest {String}
  • str {String}
  • options {Options}

.writeYAML

Aynchronously write YAML to disk, creating any intermediary directories if they don't exist.

Params

  • dest {String}
  • str {String}
  • options {Options}

.writeDataSync

Synchronously write JSON or YAML to disk, creating any intermediary directories if they don't exist. Data type is determined by the dest file extension.

Params

  • dest {String}
  • str {String}
  • options {Options}

Example

writeDataSync('foo.yml', {foo: "bar"});

.writeData

Asynchronously write JSON or YAML to disk, creating any intermediary directories if they don't exist. Data type is determined by the dest file extension.

Params

  • dest {String}
  • data {String}
  • options {Options}
  • cb {Function}: Callback function

Example

writeData('foo.yml', {foo: "bar"});

.copyFileSync

Copy files synchronously;

Params

  • src {String}
  • dest {String}

.rmdir

Asynchronously remove dirs and child dirs that exist.

Params

  • dir {String}
  • {Function}: `cb
  • returns {Function}

.del

Delete folders and files recursively. Pass a callback as the last argument to use utils.async.

Params

  • patterns {String}: Glob patterns to use.
  • options {Object}: Options for matched.
  • cb {Function}

.ext

Return the file extension.

Params

  • filepath {String}
  • returns {String}

.dirname

Directory path excluding filename.

Params

  • filepath {String}
  • returns {String}

.last

The last n segments of a filepath. If a number isn't passed for n, the last segment is returned.

Params

  • filepath {String}
  • returns {String}

.first

The first n segments of a filepath. If a number isn't passed for n, the first segment is returned.

Params

  • filepath {String}
  • returns {String}

.lastChar

Returns the last character in filepath

Params

  • filepath {String}
  • returns {String}

Example

lastChar('foo/bar/baz/');
//=> '/'

.addSlash

Add a trailing slash to the filepath.

Note, this does not consult the file system to check if the filepath is file or a directory.

Params

  • filepath {String}
  • returns {String}

.normalizePath

Normalize a filepath and remove trailing slashes.

Params

  • filepath {String}
  • returns {String}

.relative

Resolve the relative path from a to `b.

Params

  • filepath {String}
  • returns {String}

.isAbsolute

Return true if the path is absolute.

Params

  • {[type]}: filepath
  • returns {Boolean}

.equivalent

Return true if path a is the same as path `b.

Params

  • filepath {String}
  • a {String}
  • b {String}
  • returns {Boolean}

.doesPathContain

True if descendant path(s) contained within ancestor path. Note: does not test if paths actually exist.

Sourced from [Grunt].

Params

  • ancestor {String}: The starting path.
  • returns {Boolean}

.isPathCwd

True if a filepath is the CWD.

Sourced from [Grunt].

Params

  • filepath {String}
  • returns {Boolean}

.isPathInCwd

True if a filepath is contained within the CWD.

Params

  • filepath {String}
  • returns {Boolean}

Related projects

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on November 17, 2015.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].