0.0.24 • Published 7 years ago

nsync-fs v0.0.24

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

nsync-fs

This module is used by the Learn IDE, via the Learn IDE Tree package, to mirror a remote filesystem on the client's local machine. This is accomplished by both by maintaining a virtual filesystem that reflects the remote's full tree along with some data about each node (exposed by the included nsync.fs module), and by copying the remote files to the local disk. All of this is synchronized over a websocket connection, which can be shared by multiple processes via atom-socket.

Installation

$ npm install nsync-fs --save

Usage

Configure, then wait for the primary node to be set before using the nsync.fs module:

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

nsync.configure({
  localRoot: '/path/to/local-mirror',
  connection: {
    url: 'wss://ide.learn.co/file_sync_server'
  }
});

nsync.onDidSetPrimary(function(data) {
  var fs = nsync.fs; 
  var stat = fs.statSync('/some/remote/path'); // stat object of remote path
})

Custom Commands

Custom commands can be passed from the server to the client, to be handled like this:

nsync.onDidReceiveCustomCommand(function(commandPayload) {
  console.log('Custom command received:', commandPayload);
});

For example, the Learn IDE's server watches a file on the remote filesystem, ~/.custom_commands.log, which can be written to by any process running on the host. It only requires that the write be a line of valid JSON with a command key:

{"command": "atom_open", "path": "/some/remote/path"}

The server then sends this line to the client, where it is parsed into an object and passed along to the callbacks defined with onDidReceiveCustomCommand. For more on this, see how custom commands are handled in the Learn IDE Tree.

Development

This project is written in coffescript, use the default gulp task to start watching ./src/ and transpiling to ./lib/:

$ git clone https://github.com/learn-co/nsync-fs.git
$ cd nsync-fs
$ npm install
$ npm link
$ gulp
0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago