
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Create links between files cross-platform
$ npm install lnk --save
$ tree
.
└── assets
├── favicon.ico
└── style
├── app.css
└── vendor.css
2 directories, 3 files
const lnk = require('lnk');
lnk(['assets/favicon.ico', '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
lnk
don't support globbing by itself, lnk
supports arrays of targets and Promises which resolve to these though:
const lnk = require('lnk');
const globby = require('globby'); // npm install globby
lnk(globby('assets/*'), 'dist')
.then(() => console.log('done'));
lnk
provides a cross-platform convenience wrapper for the fs.link
and fs.symlink
functions.
Returns a Promise
.
Synchronous version of lnk
.
Type: string|string[]
Targets of the links. lnk()
additionally supports Promise<string|string[]>
.
Type: string
Destination directory.
Type: object
Type: string
Default: process.cwd()
The current working directory for targets
and directory
.
Type: boolean
Default: false
Overwrite existing files.
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.
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}, ...);
Type: string|object|function(object):(string|object)
Filepath or function mapping a path object to a filename or path object; used to modify the path of the link before creating.
$ tree
.
└── assets
├── favicon.ICO
└── style
├── app.css
└── vendor.css
const path = require('path');
Promise.all([
lnk('assets/style', 'dist', {rename: 'css'}),
lnk('assets/favicon.ICO', 'dist', {rename: pathOfLink => pathOfLink.base.toLowerCase()})
]).then(() => console.log('done'));
$ tree
.
├── assets
│ ├── favicon.ICO
│ └── style
│ ├── app.css
│ └── vendor.css
└── dist
├── css -> ../assets/style // symlink; directory junction on windows
└── favicon.ico // hard link to assets/favicon.ICO
$ tree
.
└── assets
├── favicon.ico
└── style
├── app.css
└── vendor.css
const rename = pathOfLink => Object.assign(pathOfLink, {
dir: path.join(pathOfLink.dir, '42'),
base: `prefix-${pathOfLink.name}` + pathOfLink.ext.toLowerCase()
});
lnk(['assets/favicon.ico', 'assets/style'], 'dist', {rename})
.then(() => console.log('done'));
$ tree
.
├── assets
│ ├── favicon.ico
│ └── style
│ ├── app.css
│ └── vendor.css
└── dist
└── 42
├── prefix-favicon.ico // hard link to assets/favicon.ico
└── prefix-style -> ../../assets/style // symlink; directory junction on windows
Type: function
Default: (level, prefix, message) => {}
A logger function, you may want to use console.log
or npmlog.log
, see npmlog documentation for details.
glob
support for multiple patternsMIT © Michael Mayer
FAQs
Create links between files cross-platform
The npm package lnk receives a total of 5,844 weekly downloads. As such, lnk popularity was classified as popular.
We found that lnk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.