1.0.39 • Published 8 years ago

promisify-fs v1.0.39

Weekly downloads
10
License
MIT
Repository
github
Last release
8 years ago

promisify-fs

This is a 'fs' promising wrapper for file operations which contains various fs-related common tasks. it will make your code more concise, neat and efficient.

promisify-fs aims to make file operation more intuitive. In addition, to make code more concise and neat. All methods are constructed by following promising way.

Usage

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

fs
  .fileExists('../index.js')
  .then(function(stat){
    console.log(stat.abs_path);
    console.log(stat.size)
  })
  .catch(function(e){
    console.error(e);
  })

//many options in stat, please refer to
//https://nodejs.org/api/fs.html#fs_class_fs_stats

fs
  .folderExists('../node_modules')
  .then(function(abs_path){
    console.log(abs_path);
  })
  .catch(function(e){
    console.error(e);
  })

fs
  .readFile('../inde1x.js')
  .then(function(fi) {
    console.log(fi);
  })
  .catch(function(e) {
    console.log('---->', e);
  })


fs
  .writeFile('../inde1x.js')
  .then(function(fi) {
    console.log(fi);
  })
  .catch(function(e) {
    console.log('---->', e);
  })

API

  • fileExists(file_path)
  • folderExists(folder_path)
  • readFile(file_path, options)
  • readJSON(file_path,options)
  • delFile(file_path)
  • writeFile(file_path, data, options)
  • getModulePackInfo(module)

if data is neither Buffer nor String, JSON.stringify will be applied with extra two optional params in options,replacer

YOU KNOW WHAT YOU ARE DOING !!!!! forcely to delete all files in this folder recursively.

  • addFolder(folder_path)

It will create folders recursively by default.

  • cloneFolder(source_path,dest_path,force)

clone folder or files within it to a dest folder.

continuing...

If you want to have all asynchronous methods operating file, please refer to bluebird library.

Good Library Companions

1.0.39

8 years ago

1.0.38

8 years ago

1.0.37

8 years ago

1.0.36

8 years ago

1.0.35

8 years ago

1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

8 years ago

1.0.30

8 years ago

1.0.29

8 years ago

1.0.28

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago