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

  • 0.4.3
  • Source
  • npm
  • Socket score

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

lnk Build Status Coverage Status

Create links between files.

Install

# CLI
$ [sudo] npm install lnk --global

# API
$ npm install lnk --save

Usage

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

2 directories, 3 files
$ lnk assets/* dist

or:

var lnk = require('lnk');
var glob = require('glob').sync; // npm install glob --save-dev

lnk(glob('assets/*'), 'dist', function(err) {
  console.log('done');
});
$ tree
.
├── assets
│   ├── favicon.ico
│   └── style
│       ├── app.css
│       └── vendor.css
└── dist
    ├── favicon.ico              // hard link to assets/favicon.ico
    └── style -> ../assets/style // directory junction on windows

4 directories, 4 files

CLI

$ lnk --help
Create links between files.

Usage: lnk [OPTION]... TARGET... DIRECTORY

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.

Options:
  -f, --force      Overwrite existing files
  -h, --hard       Create hard links instead of default behavior
  -s, --symbolic   Create symbolic links instead of default behavior
  -j, --junction   Create directory junctions (symbolic links on modern OSs)
                   instead of default behavior
  -d, --directory  Create directory symbolic links (symbolic links on modern
                   OSs) instead of default behavior
  -p, --parents    Use full source file name under DIRECTORY
  -v, --verbose    Explain what is being done
  --version        Display version information
  --help           Show help

Report lnk bugs to <https://github.com/schnittstabil/lnk/issues>
lnk home page: <https://github.com/schnittstabil/lnk>

Npm Scripts

For platform independent glob support use globstar:

$ npm install globstar --save-dev

Please note that Windows needs double quotes:

  "scripts": {
    "link-assets": "globstar --node -- lnk \"assets/*\" dist",
  },

Link your assets/* files:

$ npm run link-assets

API

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

lnk(targets, directory, [opts], callback)

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

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/*.css', 'dist/assets/style', ...);

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

Type: function

Default: function noop(level, prefix, message) {}

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

callback(err)

Type: function

  • cpy if you need to copy multiple files
  • rimraf if you need to delete files and directories
  • mkdirp if you need to create a directory recursively

License

Copyright © 2015 Michael Mayer

Licensed under the MIT license.

Keywords

FAQs

Package last updated on 21 Mar 2015

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