Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lnk

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lnk

Create links between files cross-platform

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.5K
decreased by-7.03%
Maintainers
1
Weekly downloads
 
Created
Source

lnk Build Status Build status Coverage Status XO code style

Create links between files cross-platform

Why

  • Promise interface
  • Create hard links, directory junctions and symbolic links depending on the platform

Install

$ npm install lnk --save

Usage

$ tree
.
└── assets
    ├── favicon.ico
    └── style
        ├── app.css
        └── vendor.css

2 directories, 3 files
const lnk = require('lnk');

Promise.all([
	lnk('assets/favicon.ico', 'dist'),
	lnk('assets/style', 'dist')
])
.then(() => console.log('done'));

$ tree
.
├── assets
│   ├── favicon.ico
│   └── style
│       ├── app.css
│       └── vendor.css
└── dist
    ├── favicon.ico              // hard link to assets/favicon.ico
    └── style -> ../assets/style // symlink; directory junction on windows

4 directories, 4 files

Glob support

lnk don't support globbing by itself, lnk supports arrays of targets though:

const lnk = require('lnk');
const globby = require('globby');  // npm install globby
 
globby('assets/*')
	.then(assets => lnk(assets, 'dist'));

API

lnk provides a cross-platform convenience wrapper for the fs .link and .symlink functions.

lnk(targets, directory, [opts])

Returns a Promise.

lnk.sync (targets, directory, [opts])

Synchronous version of lnk.

targets

Type: string or array of strings

Targets of the links.

directory

Type: string

Destination directory.

opts

Type: object

cwd

Type: string
Default: process.cwd()

The current working directory for targets and directory.

force

Type: boolean
Default: false

Overwrite existing files.

type

Type: string
Values: 'default', 'hard', 'symbolic', 'junction' or 'directory'
Default: 'default'

By 'default', lnk tries to create hard links, if this fails for a target because it is a directory lnk tries to create a directory junction (symbolic link on modern OSs) for this target.

parents

Type: boolean
Default: false

Use full source file name under directory.

// w/o parents:
lnk('assets/style/foo.css', 'dist/assets/style', ...);

// w/ parents:
lnk('assets/style/foo.css', 'dist', {parents: true}, ...);
log

Type: function
Default: (level, prefix, message) => {}

A logger function, you may want to use console.log or npmlog.log, see npmlog documentation for details.

  • lnk-cli – CLI version of this project
  • globby – if you need glob support for multiple patterns
  • cpy – if you need to copy multiple files
  • del – if you need to delete files and folders

License

MIT © Michael Mayer

Keywords

FAQs

Package last updated on 29 Sep 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc