Skip to content

bestikk/bestikk-fs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bestikk FS

Travis build status npm version

A simple tool to do common file operations.

Install

$ npm i --save-dev bestikk-fs

Usage

const bfs = require('bestikk-fs')

// Synchronously remove 'confidential' directory recursively
bfs.removeSync('confidential');

// Synchronously create 'foo', 'bar' and 'baz' directories
bfs.mkdirsSync('foo/bar/baz');

// Synchronously copy 'foo' directory and all its content to 'bar' directory
bfs.copySync('foo', 'bar');

// Walk through a directory and call the callback function on each file
bfs.walk('foo', (path, stat) => console.log('path: ' + path + ', stat:' + stat))

// Asynchronously untar 'foo.tar.gz' to 'bar' directory (and rename tar base directory to 'qux')
bfs.untar('foo.tar.gz', 'qux', 'bar')
  .then(() => /* do something */)

// Synchronously concat the content of 'foo', 'bar', 'baz' files into 'quz'
bfs.concatSync(['foo', 'bar', 'baz'], 'quz');

// Synchronously copy 'foo' file to 'bar' directory (ie. file will be copied to 'bar/foo')
bfs.copyToDirSync('foo', 'bar');

// Synchronously update the version in 'package.json' with '1.0.0'
bfs.updateFileSync('package.json', /"version": "(.*?)"/g, '"version": "1.0.0"');