# nsync-fs

> A virtual file system for Atom, synchronized with a remote physical file system

Latest version **0.0.24** (published 2017-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install nsync-fs
pnpm add nsync-fs
yarn add nsync-fs
bun add nsync-fs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.24 |
| Published | 2017-07-27 |
| First published | 2016-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | drewprice, joshrowley |

## Links

- npm: https://www.npmjs.com/package/nsync-fs
- Repository: https://github.com/learn-co/nsync-fs
- Homepage: https://github.com/learn-co/nsync-fs#readme
- Issues: https://github.com/learn-co/nsync-fs/issues
- npm.io page: https://npm.io/package/nsync-fs

## Dependencies (7)

- [trash](https://npm.io/package/trash.md) 4.0.0
- [dotenv](https://npm.io/package/dotenv.md) 2.0.0
- [fs-plus](https://npm.io/package/fs-plus.md) ^2.9.3
- [event-kit](https://npm.io/package/event-kit.md) 1.0.0
- [atom-socket](https://npm.io/package/atom-socket.md) 0.0.8
- [graceful-fs](https://npm.io/package/graceful-fs.md) 4.1.6
- [underscore-plus](https://npm.io/package/underscore-plus.md) 1.0.0

## Recent versions

- 0.0.24 (latest) — 2017-07-27
- 0.0.23 — 2017-07-26
- 0.0.22 — 2017-06-26
- 0.0.21 — 2017-01-18
- 0.0.20 — 2017-01-17
- 0.0.19 — 2016-11-22
- 0.0.18 — 2016-11-22
- 0.0.17 — 2016-11-21
- 0.0.16 — 2016-11-15
- 0.0.15 — 2016-11-15
- 0.0.14 — 2016-11-14
- 0.0.13 — 2016-11-14
- 0.0.12 — 2016-11-14
- 0.0.11 — 2016-11-14
- 0.0.10 — 2016-11-09
- … 9 more at https://npm.io/package/nsync-fs/versions

## README

# nsync-fs
This module is used by the [Learn IDE](https://github.com/learn-co/learn-ide), via the [Learn IDE Tree](https://github.com/learn-co/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](https://github.com/learn-co/nsync-fs).

### Installation
```shell
$ npm install nsync-fs --save
```

### Usage
Configure, then wait for the primary node to be set before using the `nsync.fs` module:
```javascript
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:
```javascript
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:

```json
{"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](https://github.com/learn-co/learn-ide-tree/blob/f3314a482cc19b42bcc99f9fc40c6b38a9ef0dbc/lib/nsync/nsync-helper.coffee#L163-L164).

### Development
This project is written in coffescript, use the default `gulp` task to start watching `./src/` and transpiling to `./lib/`:
```shell
$ git clone https://github.com/learn-co/nsync-fs.git
$ cd nsync-fs
$ npm install
$ npm link
$ gulp
```

---
_Source: https://npm.io/package/nsync-fs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
