# nodesync

> node scripts for watching changed files and dirs then post them to remote server

Latest version **0.0.30** (published 2013-12-11) · BSD license · 0 weekly downloads

## Install

```sh
npm install nodesync
pnpm add nodesync
yarn add nodesync
bun add nodesync
```

Provides the command `nodesync`.

## 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.30 |
| Published | 2013-12-11 |
| First published | 2013-09-11 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | wangyuzju |
| Maintainers | wangyu0248 |
| Keywords | node, autosync, wacth |

## Links

- npm: https://www.npmjs.com/package/nodesync
- Repository: git@github.com:wangyuzju/nodesync
- Issues: https://github.com/wangyuzju/nodesync/issues
- npm.io page: https://npm.io/package/nodesync

## Dependencies (5)

- [MD5](https://npm.io/package/MD5.md) ~1.1.0
- [coffess](https://npm.io/package/coffess.md) ~0.0.3
- [commander](https://npm.io/package/commander.md) ~0.6.0
- [form-data](https://npm.io/package/form-data.md) ~0.1.0
- [watch-project](https://npm.io/package/watch-project.md) ~0.0.7

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.0.30 (latest) — 2013-12-11
- 0.0.28 — 2013-12-11
- 0.0.26 — 2013-12-11
- 0.0.25 — 2013-11-18
- 0.0.24 — 2013-10-10
- 0.0.23 — 2013-10-10
- 0.0.22 — 2013-10-10
- 0.0.21 — 2013-10-09
- 0.0.20 — 2013-10-09
- 0.0.19 — 2013-09-25
- 0.0.18 — 2013-09-24
- 0.0.17 — 2013-09-23
- 0.0.16 — 2013-09-23
- 0.0.15 — 2013-09-23
- 0.0.14 — 2013-09-22
- … 14 more at https://npm.io/package/nodesync/versions

## README

# nodesync

监测本地文件夹，自动将变化的文件上传到服务器的指定目录下

## **注意事项**
1. 同步工具需要运行才能监测到文件的改动并进行同步，因此需要**在修改文件之前，执行程序，开始监测文件改动**。
2. 同步工具只是将代码同步到开发机，**没有提交到SVN**，在开发机上预览效果无误之后，请记得**手动提交代码到SVN**。
3. 建议以强制同步模式运行程序，即`nodesync -f`，虽然会强制覆盖文件，但是由于代码最终是通过SVN提交，因此不会导致冲突



## Install

```
npm install -g nodesync
```

## Usage

```
nodesync         # 当前目录没有配置文件会自动运行配置引导，相当于执行 nodesync config
nodesync -f      # 强制同步方式(建议使用)
nodesync -p src/ # 监听当前目录下的src目录内的文件变动
```
开始监控并自动同步改动文件


```
nodesync config
```
根据当前的配置文件，重新设置配置文件

## Init && Configuration

假如需要监控 ~/workspace/music-branch-119/src/site/ 目录（music/为项目根目录），并同步到/bae/home/user/branch/music/src/site，可以采用以下方法

### 方法一: 自动生成配置文件
1. 切换**项目根目录** ~/workspace/music-branch-119/（其实任意，只要下此还在该目录调用nodesync就行，不然会找不到配置文件）
2. 第一次执行，需要输入以下配置信息（根据提示的默认值酌情修改）
  + path: 需要监控的本地文件夹的相对路径（如：src/site/，**"./"表示监测本目录下的全部文件**）
  + ignore: 忽略监控的文件类型（如: "*.swp, *.bak"）
  + host: 服务器接收脚本URL，回车即可
  + pathto: 项目文件存放到服务器上的绝对路径。（**/bae/home/user/branch/music/**）
3. 提示配置文件.m3dsync_config保存成功，后续可直接通过该文件修改配置
4. **nodesync**, 改动的文件会文件自动同步到开发机

### 方法二：手动填写配置文件
1. cp sample.m3dsync_config ~/workspace/music/.m3dsync_config
2. vim .m3dsync_config

``` javascript
{
  "path": "src/test/",  // "./"
  "ignore": "*.swap, *.bak, test*",
  "host": "http://config.music.baidu.com/nodesync",
  "pathto": "/bae/home/user/branch/music/"

  /*以下为可选参数*/
  "force": true,      //默认执行nodesync -f

}
```

## 常见错误说明
### Error: watch EMFILE: Too many opened files.
OS X系统默认ulimit被设置成256（查看方式：ulimit -n）,调大该值即可：`ulimit -n 16384`

### file md5 not match, please check your version and try svn up.
由于多人同时修改，导致开发机器上的文件有别人的改动，会报此提示。建议**运行程序时将上-f参数**，如`nodesync -f`，这样就会强制同步当前保存的文件到开发机
（PS：开发机只是提供预览效果，覆盖了别人的改动也没有关系，最终的代码是通过SVN提交，冲突通过SVN解决）


## TODO
- 自动冲突解决、冲突提示强制覆盖
- 离线文件改动监测
- 修复win下监测大量文件时CPU占用较高的问题


# change log
1. 0.0.7 add stable mode (using "chokidar") for supporting old version of nodejs(0.8) and OSX(10.7)
2. 0.0.10 add file filter feature
3. 0.0.25 add `nodesync -l` option for local testing

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