Giter Club home page Giter Club logo

fsops's Introduction

fsops

fsops operates on files and directories in a serial synchronuous way. Includes mkdirs, recursive delete, copy changed, reapply changes

Core operations:

  • copyFile : copies files unless same contents exist at that path
  • copyUpdated : copies new and updated files and directories
  • listRecursively
  • mkdirs
  • deleteRecursively
  • showChangesToReapply : performs a diff between a 2 dirs considered 'newer' and 'older'.
  • reapplyChanges : applies changes needed to get another dir in the same state

Example:

// require the fsops module
var fsops = require("fsops");

// copy a file
var copied = fsops.copyFile('/tmp/test.txt', '/tmp/test2.txt')
// copied will be true unless test2.txt already existed with same content

// copy all new and updated files below myUpdatedDir to myOlderVersionDir
var changeCount = fsops.copyUpdated('/tmp/myUpdatedDir', '/tmp/myOlderVersionDir')
// changeCount shows the number of files


// lists recursively, returning the full paths
var paths = fsops.listRecursively('/home/jbosmans')
// paths is an array of filepaths

// lists recursively, returning the data
var metaArray = fsops.listRecursivelyMeta('/home/jbosmans')
// array of instances of fsops.ListedPathMeta

// delete recursively
var deletedCount = fsops.deleteRecursively('/tmp/bigDir')

// creates necessary parents for 'myDir' to be created
var createdCount = fsops.mkdirsSync('/tmp/my/new/myDir')

// calculate a diff between updatedDir and olderDir:
// which operations are required to get olderDir in the same state as updatedDir
// returns an instance of fsops.DirectoryChangesMeta
var meta = fsops.showChangesToReapply('/tmp/updatedDir', '/tmp/olderDir')
// meta is an instance of fsops.DirectoryChangesMeta

// reapplie changes that were made to updatedDir to olderDir
// so that olderDir ends up in the same state as updatedDir
fsops.reapplyChangesToDir('/tmp/updatedDir', '/tmp/olderDir')
var equal = fsops.equalContent('/tmp/someDir', '/tmp/otherDir')
// equal will be true if both dirs have same child dirs and files with same content (per checksum)

//calculate a unified view of changes, showing only top level added and deleted directories.
var meta = fsops.showChangesToReapply('/tmp/updatedDir', '/tmp/olderDir'))
var summary = fsops.createSummaryOfChanges(meta);

//generates output to console
fsops.logDiffSummary(meta);

fsops is licensed under the Apache License, Version 2.0

fsops's People

Contributors

jonathanibm avatar jbosmans avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.