{"id":17999513,"url":"https://github.com/ozum/not-sync","last_synced_at":"2025-04-04T07:14:59.089Z","repository":{"id":141712747,"uuid":"330447548","full_name":"ozum/not-sync","owner":"ozum","description":"Disable synchronization for files in cloud storage such as Dropbox, iCloudDrive or OneDrive. Detects cloud storage provider.","archived":false,"fork":false,"pushed_at":"2021-02-11T09:43:52.000Z","size":1043,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T10:12:20.101Z","etag":null,"topics":["cloud-storage","disable","dropbox","icloud-drive","onedrive","sync"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ozum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-17T17:30:24.000Z","updated_at":"2021-02-11T09:41:53.000Z","dependencies_parsed_at":"2023-05-23T00:00:11.164Z","dependency_job_id":null,"html_url":"https://github.com/ozum/not-sync","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnot-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnot-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnot-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnot-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozum","download_url":"https://codeload.github.com/ozum/not-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135147,"owners_count":20889421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-storage","disable","dropbox","icloud-drive","onedrive","sync"],"created_at":"2024-10-29T22:13:20.470Z","updated_at":"2025-04-04T07:14:59.074Z","avatar_url":"https://github.com/ozum.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# not-sync\n\nDisable synchronization for files in cloud storage such as Dropbox, iCloudDrive or OneDrive. Detects cloud storage provider.\n\n# Synopsis\n\n```ts\nimport { notSync, resync } from \"not-sync\";\n```\n\n```ts\n// Disable synchronization for following directories.\nawait notSync([\"node_modules\", \"coverage\", \"dist\"]);\n```\n\n```ts\n// Provide cwd for a project located in `${os.homedir()}/Dropbox/project`.\nawait notSync([\"node_modules\", \"coverage\", \"dist\"], { cwd: `${os.homedir()}/Dropbox/project` });\n```\n\n```ts\n// If new new files are added to project directory (e.g. iCloudDrive .nosync files) add new files\n// to closest \".gitignore\". (Here \"node_modules.nosync\", \"coverage.nosync\", \"dist.nosync\")\nawait notSync([\"node_modules\", \"coverage\", \"dist\"], { ignoreConfigs: [\".gitignore\"] });\n```\n\n```ts\n// Enable synchronization for following directories.\nawait resync([\"node_modules\", \"coverage\", \"dist\"]);\n```\n\n```ts\nawait notSync([\"node_modules\", \"coverage\", \"dist\"], {\n  cwd: \"path/to/cwd\",\n  ignoreConfigs: [\".gitignore\", \".prettierignore\"],\n  dry: false;\n  ci: false,\n  on: {\n    found: (service, files) =\u003e { },\n    notFound: (files) =\u003e { },\n    move: (service, from, to) =\u003e { },\n    moveFail: (service, errorCode, from, to) =\u003e { },\n    symlink: (service, target, path) =\u003e { },\n    delete: (service, path, type) =\u003e { },\n    addEntry: (service, ignoreFile, entries) =\u003e { },\n    deleteEntry: (service, ignoreFile, entries) =\u003e { },\n  },\n  verbose: false,\n  roots: {\n    iCloudDrive: os.platform() === \"darwin\"\n      ? `${os.homedir()}/Library/Mobile Documents/com~apple~CloudDocs/`\n      : `${os.homedir()}/iCloudDrive`,\n    dropBox: `${os.homedir()}/Dropbox`,\n    oneDrive: `${os.homedir()}/OneDrive`\n  }\n  targetRoots: {\n    iCloudDrive: `${iCloudDriveRoot}/../iCloudDrive Linked Files`\n    dropBox: `${dropboxRoot}/../Dropbox Linked Files`,\n    oneDrive: `${oneDriveRoot}/../OneDrive Linked Files`,\n  }\n  linkSameDir: true, // Add \".nosync\" files to near of original files for \"iCloudDrive\".\n})\n```\n\n## Minimal CLI\n\nFor more advanced options, please use [not-sync-cli](https://www.npmjs.com/package/not-sync-cli)\n\n```sh\n$ not-sync node_modules,dist,coverage\n$ resync node_modules,dist,coverage\n```\n\n# Details\n\nThis module disables and enables synchronization of given files and directories from cloud storage. Possibly could be used to save space, time and sometimes prevent headache, especially for heavy by size and number of files directories such as `node_modules`.\n\n`notSync` function moves files/directories to another non-synchronized path (see table below) and creates a symbolic link in place of original files. `resync` function deletes symbolic links and moves files back to original place.\n\n# Features\n\n- Does not execute commands on a CI (Continous Integration) environment. To enable set `options.ci` to true.\n- Could be used more than one cloud storage services.\n- Provides `resync` method for undoing changes.\n- Auto detect cloud storage service from file path.\n- Could use `.nosync` extension for `iCloudDrive`.\n- Minimal CLI. For more advanced options, please use [not-sync-cli](https://www.npmjs.com/package/not-sync-cli)\n\nBelow are examples for `node_modules` directory located in a `project`:\n\n| Service     | Option               | Source                                | Target                                                          |\n| ----------- | -------------------- | ------------------------------------- | --------------------------------------------------------------- |\n| iCloudDrive |                      | `${iCloudDrive}/project/node_modules` | `${iCloudDrive}/project/node_modules.nosync`                    |\n| iCloudDrive | `linkSameDir: false` | `${iCloudDrive}/project/node_modules` | `${os.homedir()}/iCloudDrive Linked Files/project/node_modules` |\n| Dropbox     |                      | `${Dropbox}/project/node_modules`     | `${os.homedir()}/Dropbox Linked Files/project/node_modules`     |\n| OneDrive    |                      | `${OneDrive}/project/node_modules`    | `${os.homedir()}/OneDrive Linked Files/project/node_modules`    |\n\nTarget directory can be changed using `targetRoots` option.\n\n\u003c!-- usage --\u003e\n\n\u003c!-- commands --\u003e\n\n# API\n\n\u003ca name=\"readmemd\"\u003e\u003c/a\u003e\n\nnot-sync\n\n# not-sync\n\n## Table of contents\n\n### Interfaces\n\n- [Events](#interfaceseventsmd)\n- [Options](#interfacesoptionsmd)\n\n### Type aliases\n\n- [MoveErrorCode](#moveerrorcode)\n- [OnAddEntry](#onaddentry)\n- [OnDelete](#ondelete)\n- [OnDeleteEntry](#ondeleteentry)\n- [OnFound](#onfound)\n- [OnMove](#onmove)\n- [OnMoveFail](#onmovefail)\n- [OnNotFound](#onnotfound)\n- [OnSymlink](#onsymlink)\n- [ServiceKey](#servicekey)\n\n### Functions\n\n- [notSync](#notsync)\n- [resync](#resync)\n\n## Type aliases\n\n### MoveErrorCode\n\nƬ **MoveErrorCode**: _NOSRC_ \\| _LINKEXIST_ \\| _NOTALINK_ \\| _NOTFOUND_ \\| _NOTARGET_\n\nDefined in: [index.ts:6](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L6)\n\n---\n\n### OnAddEntry\n\nƬ **OnAddEntry**: (`service`: [_ServiceKey_](#servicekey), `ignoreFile`: _string_, `entries`: _string_[]) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:13](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L13)\n\n---\n\n### OnDelete\n\nƬ **OnDelete**: (`service`: [_ServiceKey_](#servicekey), `path`: _string_, `type`: _symlink_ \\| _parent_) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:12](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L12)\n\n---\n\n### OnDeleteEntry\n\nƬ **OnDeleteEntry**: (`service`: [_ServiceKey_](#servicekey), `ignoreFile`: _string_, `entries`: _string_[]) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:14](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L14)\n\n---\n\n### OnFound\n\nƬ **OnFound**: (`service`: [_ServiceKey_](#servicekey), `files`: _string_[]) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:7](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L7)\n\n---\n\n### OnMove\n\nƬ **OnMove**: (`service`: [_ServiceKey_](#servicekey), `from`: _string_, `to`: _string_) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:9](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L9)\n\n---\n\n### OnMoveFail\n\nƬ **OnMoveFail**: (`service`: [_ServiceKey_](#servicekey), `errorCode`: [_MoveErrorCode_](#moveerrorcode), `from?`: _string_, `to?`: _string_) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:10](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L10)\n\n---\n\n### OnNotFound\n\nƬ **OnNotFound**: (`files`: _string_[]) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:8](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L8)\n\n---\n\n### OnSymlink\n\nƬ **OnSymlink**: (`service`: [_ServiceKey_](#servicekey), `target`: _string_, `path`: _string_) =\u003e _any_ \\| _Promise_\u003c_any_\\\u003e\n\nDefined in: [index.ts:11](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L11)\n\n---\n\n### ServiceKey\n\nƬ **ServiceKey**: _iCloudDrive_ \\| _dropbox_ \\| _oneDrive_\n\nDefined in: [cloud-service/cloud-service.ts:21](https://github.com/ozum/not-sync/blob/b05a50d/src/cloud-service/cloud-service.ts#L21)\n\n## Functions\n\n### notSync\n\n▸ **notSync**(`paths`: _string_[], `options?`: [_Options_](#interfacesoptionsmd)): _Promise_\u003c_void_\\\u003e\n\n#### Parameters:\n\n| Name      | Type                              | Default value |\n| --------- | --------------------------------- | ------------- |\n| `paths`   | _string_[]                        | -             |\n| `options` | [_Options_](#interfacesoptionsmd) | ...           |\n\n**Returns:** _Promise_\u003c_void_\\\u003e\n\nDefined in: [main.ts:34](https://github.com/ozum/not-sync/blob/b05a50d/src/main.ts#L34)\n\n---\n\n### resync\n\n▸ **resync**(`paths`: _string_[], `options?`: [_Options_](#interfacesoptionsmd)): _Promise_\u003c_void_\\\u003e\n\n#### Parameters:\n\n| Name      | Type                              | Default value |\n| --------- | --------------------------------- | ------------- |\n| `paths`   | _string_[]                        | -             |\n| `options` | [_Options_](#interfacesoptionsmd) | ...           |\n\n**Returns:** _Promise_\u003c_void_\\\u003e\n\nDefined in: [main.ts:30](https://github.com/ozum/not-sync/blob/b05a50d/src/main.ts#L30)\n\n# Interfaces\n\n\u003ca name=\"interfaceseventsmd\"\u003e\u003c/a\u003e\n\n[not-sync](#readmemd) / Events\n\n# Interface: Events\n\n## Hierarchy\n\n- **Events**\n\n## Table of contents\n\n### Properties\n\n- [addEntry](#addentry)\n- [delete](#delete)\n- [deleteEntry](#deleteentry)\n- [found](#found)\n- [move](#move)\n- [moveFail](#movefail)\n- [notFound](#notfound)\n- [symlink](#symlink)\n\n## Properties\n\n### addEntry\n\n• `Optional` **addEntry**: _undefined_ \\| [_OnAddEntry_](#onaddentry)\n\nDefined in: [index.ts:23](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L23)\n\n---\n\n### delete\n\n• `Optional` **delete**: _undefined_ \\| [_OnDelete_](#ondelete)\n\nDefined in: [index.ts:22](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L22)\n\n---\n\n### deleteEntry\n\n• `Optional` **deleteEntry**: _undefined_ \\| [_OnDeleteEntry_](#ondeleteentry)\n\nDefined in: [index.ts:24](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L24)\n\n---\n\n### found\n\n• `Optional` **found**: _undefined_ \\| [_OnFound_](#onfound)\n\nDefined in: [index.ts:17](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L17)\n\n---\n\n### move\n\n• `Optional` **move**: _undefined_ \\| [_OnMove_](#onmove)\n\nDefined in: [index.ts:19](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L19)\n\n---\n\n### moveFail\n\n• `Optional` **moveFail**: _undefined_ \\| [_OnMoveFail_](#onmovefail)\n\nDefined in: [index.ts:20](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L20)\n\n---\n\n### notFound\n\n• `Optional` **notFound**: _undefined_ \\| [_OnNotFound_](#onnotfound)\n\nDefined in: [index.ts:18](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L18)\n\n---\n\n### symlink\n\n• `Optional` **symlink**: _undefined_ \\| [_OnSymlink_](#onsymlink)\n\nDefined in: [index.ts:21](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L21)\n\n\u003ca name=\"interfacesoptionsmd\"\u003e\u003c/a\u003e\n\n[not-sync](#readmemd) / Options\n\n# Interface: Options\n\nOptions\n\n## Hierarchy\n\n- **Options**\n\n## Table of contents\n\n### Properties\n\n- [ci](#ci)\n- [createDirs](#createdirs)\n- [cwd](#cwd)\n- [dry](#dry)\n- [ignoreConfigs](#ignoreconfigs)\n- [linkSameDir](#linksamedir)\n- [on](#on)\n- [roots](#roots)\n- [targetRoots](#targetroots)\n- [verbose](#verbose)\n\n## Properties\n\n### ci\n\n• `Optional` **ci**: _undefined_ \\| _boolean_\n\nBy default \"not-sync\" does not excute any command on a CI (continous integration) environment. Set this option to true to execute on the CI.\n\nDefined in: [index.ts:48](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L48)\n\n---\n\n### createDirs\n\n• `Optional` **createDirs**: _undefined_ \\| _boolean_\n\nCreate directories for non existing paths. (If they are in a cloud path). This may be used to disable sync of directories to be created in future.\n\nDefined in: [index.ts:46](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L46)\n\n---\n\n### cwd\n\n• `Optional` **cwd**: _undefined_ \\| _string_\n\nCurrent working directory to be used for resolving relative paths.\n\nDefined in: [index.ts:30](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L30)\n\n---\n\n### dry\n\n• `Optional` **dry**: _undefined_ \\| _boolean_\n\nPrevents changes to be written to disk. Executes a dry run.\n\nDefined in: [index.ts:34](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L34)\n\n---\n\n### ignoreConfigs\n\n• `Optional` **ignoreConfigs**: _undefined_ \\| _string_ \\| _string_[]\n\nIgnore configuration files (e.g. .gitignore, .prettierignore) to add new created files if any.\n\nDefined in: [index.ts:32](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L32)\n\n---\n\n### linkSameDir\n\n• `Optional` **linkSameDir**: _undefined_ \\| _boolean_\n\nMove files near original one for iCloudDrive. For example \"node_modules\" is moved \"node_modules.nosync\" in same directory.\n\nDefined in: [index.ts:40](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L40)\n\n---\n\n### on\n\n• `Optional` **on**: _undefined_ \\| [_Events_](#interfaceseventsmd)\n\nEvent handler functions to act on several events generated during operation.\n\nDefined in: [index.ts:36](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L36)\n\n---\n\n### roots\n\n• `Optional` **roots**: _undefined_ \\| _Partial_\u003c_Record_\u003c[_ServiceKey_](#servicekey), _string_\\\u003e\\\u003e\n\nRoots of cloud services. If default roots has to be changed for same reson.\n\nDefined in: [index.ts:44](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L44)\n\n---\n\n### targetRoots\n\n• `Optional` **targetRoots**: _undefined_ \\| _Partial_\u003c_Record_\u003c[_ServiceKey_](#servicekey), _string_\\\u003e\\\u003e\n\nCustom roots for each cloud service to move files.\n\nDefined in: [index.ts:42](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L42)\n\n---\n\n### verbose\n\n• `Optional` **verbose**: _undefined_ \\| _boolean_\n\nAdds extra information to event handlers.\n\nDefined in: [index.ts:38](https://github.com/ozum/not-sync/blob/b05a50d/src/index.ts#L38)\n\n# Related\n\n[not-sync-cli](https://www.npmjs.com/package/not-sync-cli): CLI for this API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozum%2Fnot-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozum%2Fnot-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozum%2Fnot-sync/lists"}