New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

sync-snippet

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sync-snippet

Synchronize code snippet among files.

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

sync-snippet

Synchronize code snippet among files.

NPM version

How to use it?

npm i -D sync-snippet

1.Use ////sync-code-snippet:ws:start and ////sync-code-snippet:ws:end to mark snippet area in files.

a.js:

////sync-code-snippet:ws:start
////sync-code-snippet:ws:end

b.js:

////sync-code-snippet:ws:start
var a=1;
////sync-code-snippet:ws:end

c.js:

////sync-code-snippet:ws:start
////sync-code-snippet:ws:end

2.Invoke it in nodejs:

const sync = require("sync-snippet")

sync({
    name: "ws", //should be unique in this pc
    regexp: /\/\/\/\/sync-code-snippet:(\w+):(\w+) */g, //should be like this:  ////sync-code-snippet:ws:end
    files: [
        {
            path: "/home/blackmiaool/a.js"
        },
        {
            path: "/home/blackmiaool/b.js"
        },
        {
            path: "/home/blackmiaool/c.js"
        },
    ]
});

3.Try to edit the code in the snippet area and check the area in other files

Does it support indent?

Yes. It get the indentation by calculating the spaces between the column0 and the start mark and synchronize the snippet area accordingly. Remember to make the snippet area and the start mark have the same indent.

Wrong:

////sync-code-snippet:ws:start
  var a=1;
////sync-code-snippet:ws:end

Right:

  ////sync-code-snippet:ws:start
  var a=1;
  ////sync-code-snippet:ws:end

How to test it?

Clone the repo, run the start.js and try to edit the files in ./test folder.

FAQs

Package last updated on 29 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts