bestikk-fs
v1.0.0
Published
A simple tool to do common file operations
Downloads
105
Readme
Bestikk FS
ifdef::env-github[] image:http://img.shields.io/travis/bestikk/bestikk-fs.svg[Travis build status, link=https://travis-ci.org/bestikk/bestikk-fs] image:http://img.shields.io/npm/v/bestikk-fs.svg[npm version, link=https://www.npmjs.org/package/bestikk-fs] endif::[]
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"');