npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

not-sync

v1.4.1

Published

Disable synchronization for files in cloud storage such as Dropbox, iCloudDrive or OneDrive. Detects cloud storage provider.

Downloads

151

Readme

not-sync

Disable synchronization for files in cloud storage such as Dropbox, iCloudDrive or OneDrive. Detects cloud storage provider.

Synopsis

import { notSync, resync } from "not-sync";
// Disable synchronization for following directories.
await notSync(["node_modules", "coverage", "dist"]);
// Provide cwd for a project located in `${os.homedir()}/Dropbox/project`.
await notSync(["node_modules", "coverage", "dist"], { cwd: `${os.homedir()}/Dropbox/project` });
// If new new files are added to project directory (e.g. iCloudDrive .nosync files) add new files
// to closest ".gitignore". (Here "node_modules.nosync", "coverage.nosync", "dist.nosync")
await notSync(["node_modules", "coverage", "dist"], { ignoreConfigs: [".gitignore"] });
// Enable synchronization for following directories.
await resync(["node_modules", "coverage", "dist"]);
await notSync(["node_modules", "coverage", "dist"], {
  cwd: "path/to/cwd",
  ignoreConfigs: [".gitignore", ".prettierignore"],
  dry: false;
  ci: false,
  on: {
    found: (service, files) => { },
    notFound: (files) => { },
    move: (service, from, to) => { },
    moveFail: (service, errorCode, from, to) => { },
    symlink: (service, target, path) => { },
    delete: (service, path, type) => { },
    addEntry: (service, ignoreFile, entries) => { },
    deleteEntry: (service, ignoreFile, entries) => { },
  },
  verbose: false,
  roots: {
    iCloudDrive: os.platform() === "darwin"
      ? `${os.homedir()}/Library/Mobile Documents/com~apple~CloudDocs/`
      : `${os.homedir()}/iCloudDrive`,
    dropBox: `${os.homedir()}/Dropbox`,
    oneDrive: `${os.homedir()}/OneDrive`
  }
  targetRoots: {
    iCloudDrive: `${iCloudDriveRoot}/../iCloudDrive Linked Files`
    dropBox: `${dropboxRoot}/../Dropbox Linked Files`,
    oneDrive: `${oneDriveRoot}/../OneDrive Linked Files`,
  }
  linkSameDir: true, // Add ".nosync" files to near of original files for "iCloudDrive".
})

Minimal CLI

For more advanced options, please use not-sync-cli

$ not-sync node_modules,dist,coverage
$ resync node_modules,dist,coverage

Details

This 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.

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.

Features

  • Does not execute commands on a CI (Continous Integration) environment. To enable set options.ci to true.
  • Could be used more than one cloud storage services.
  • Provides resync method for undoing changes.
  • Auto detect cloud storage service from file path.
  • Could use .nosync extension for iCloudDrive.
  • Minimal CLI. For more advanced options, please use not-sync-cli

Below are examples for node_modules directory located in a project:

| Service | Option | Source | Target | | ----------- | -------------------- | ------------------------------------- | --------------------------------------------------------------- | | iCloudDrive | | ${iCloudDrive}/project/node_modules | ${iCloudDrive}/project/node_modules.nosync | | iCloudDrive | linkSameDir: false | ${iCloudDrive}/project/node_modules | ${os.homedir()}/iCloudDrive Linked Files/project/node_modules | | Dropbox | | ${Dropbox}/project/node_modules | ${os.homedir()}/Dropbox Linked Files/project/node_modules | | OneDrive | | ${OneDrive}/project/node_modules | ${os.homedir()}/OneDrive Linked Files/project/node_modules |

Target directory can be changed using targetRoots option.

API

not-sync

not-sync

Table of contents

Interfaces

Type aliases

Functions

Type aliases

MoveErrorCode

Ƭ MoveErrorCode: NOSRC | LINKEXIST | NOTALINK | NOTFOUND | NOTARGET

Defined in: index.ts:6


OnAddEntry

Ƭ OnAddEntry: (service: ServiceKey, ignoreFile: string, entries: string[]) => any | Promise<any>

Defined in: index.ts:13


OnDelete

Ƭ OnDelete: (service: ServiceKey, path: string, type: symlink | parent) => any | Promise<any>

Defined in: index.ts:12


OnDeleteEntry

Ƭ OnDeleteEntry: (service: ServiceKey, ignoreFile: string, entries: string[]) => any | Promise<any>

Defined in: index.ts:14


OnFound

Ƭ OnFound: (service: ServiceKey, files: string[]) => any | Promise<any>

Defined in: index.ts:7


OnMove

Ƭ OnMove: (service: ServiceKey, from: string, to: string) => any | Promise<any>

Defined in: index.ts:9


OnMoveFail

Ƭ OnMoveFail: (service: ServiceKey, errorCode: MoveErrorCode, from?: string, to?: string) => any | Promise<any>

Defined in: index.ts:10


OnNotFound

Ƭ OnNotFound: (files: string[]) => any | Promise<any>

Defined in: index.ts:8


OnSymlink

Ƭ OnSymlink: (service: ServiceKey, target: string, path: string) => any | Promise<any>

Defined in: index.ts:11


ServiceKey

Ƭ ServiceKey: iCloudDrive | dropbox | oneDrive

Defined in: cloud-service/cloud-service.ts:21

Functions

notSync

notSync(paths: string[], options?: Options): Promise<void>

Parameters:

| Name | Type | Default value | | --------- | --------------------------------- | ------------- | | paths | string[] | - | | options | Options | ... |

Returns: Promise<void>

Defined in: main.ts:34


resync

resync(paths: string[], options?: Options): Promise<void>

Parameters:

| Name | Type | Default value | | --------- | --------------------------------- | ------------- | | paths | string[] | - | | options | Options | ... |

Returns: Promise<void>

Defined in: main.ts:30

Interfaces

not-sync / Events

Interface: Events

Hierarchy

  • Events

Table of contents

Properties

Properties

addEntry

Optional addEntry: undefined | OnAddEntry

Defined in: index.ts:23


delete

Optional delete: undefined | OnDelete

Defined in: index.ts:22


deleteEntry

Optional deleteEntry: undefined | OnDeleteEntry

Defined in: index.ts:24


found

Optional found: undefined | OnFound

Defined in: index.ts:17


move

Optional move: undefined | OnMove

Defined in: index.ts:19


moveFail

Optional moveFail: undefined | OnMoveFail

Defined in: index.ts:20


notFound

Optional notFound: undefined | OnNotFound

Defined in: index.ts:18


symlink

Optional symlink: undefined | OnSymlink

Defined in: index.ts:21

not-sync / Options

Interface: Options

Options

Hierarchy

  • Options

Table of contents

Properties

Properties

ci

Optional ci: undefined | boolean

By default "not-sync" does not excute any command on a CI (continous integration) environment. Set this option to true to execute on the CI.

Defined in: index.ts:48


createDirs

Optional createDirs: undefined | boolean

Create 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.

Defined in: index.ts:46


cwd

Optional cwd: undefined | string

Current working directory to be used for resolving relative paths.

Defined in: index.ts:30


dry

Optional dry: undefined | boolean

Prevents changes to be written to disk. Executes a dry run.

Defined in: index.ts:34


ignoreConfigs

Optional ignoreConfigs: undefined | string | string[]

Ignore configuration files (e.g. .gitignore, .prettierignore) to add new created files if any.

Defined in: index.ts:32


linkSameDir

Optional linkSameDir: undefined | boolean

Move files near original one for iCloudDrive. For example "node_modules" is moved "node_modules.nosync" in same directory.

Defined in: index.ts:40


on

Optional on: undefined | Events

Event handler functions to act on several events generated during operation.

Defined in: index.ts:36


roots

Optional roots: undefined | Partial<Record<ServiceKey, string>>

Roots of cloud services. If default roots has to be changed for same reson.

Defined in: index.ts:44


targetRoots

Optional targetRoots: undefined | Partial<Record<ServiceKey, string>>

Custom roots for each cloud service to move files.

Defined in: index.ts:42


verbose

Optional verbose: undefined | boolean

Adds extra information to event handlers.

Defined in: index.ts:38

Related

not-sync-cli: CLI for this API.