make-symlinks
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

make-symlinks

Travis CI node npm PRs Welcome

Create symbolic link (file symlink) using glob


Install

$ npm install make-symlinks

Usage

const makeSymlinks = require('make-symlinks');
 
const patterns = ['/home/guntur/dotfiles/*', '!/home/guntur/dotfiles/.git'];
const path = '/home/guntur/';
 
makeSymlinks(patterns, path).then(symlinks => {
    symlinks.forEach(symlink => {
        console.log(symlink.path, '', symlink.target);
    });
});
 
const symlinks = makeSymlinks.sync(patterns, path);
symlinks.forEach(symlink => {
    console.log(symlink.path, '', symlink.target);
});

API

makeSymlinks(patterns, path, [options])

  • Params:
    • patterns: <string | string[]> (required) - The source files. See globby supported patterns.
    • path: <string> (required) - The directory an output of symlink(s).
    • options: <Options>
  • Returns: <Promise<object>> - Returns a promise for an array object of symlinks patterns and path.

makeSymlinks.sync(patterns, path, [options])

  • Params:
    • patterns: <string | string[]> (required) - The source files. See globby supported patterns.
    • path: <string> (required) - The directory an output of symlink(s).
    • options: <Options>
  • Returns: <Promise<object>> - Returns an array object of symlinks patterns and path.

Options

See all supported globby options.

  • cwd: <string> (optional) - The source files to resolve from.
    • Default: process.cwd()
  • force: <boolean> (optional) - Delete symlink if exists.
    • Default: false
  • dryRun: <boolean> (optional) - See what would be created symlinks.
    • Default: false

Example

const options = {
    cwd: process.env.HOME,
    dryRun: true
};
 
makeSymlinks('**/*', '/path/symlinks/dest', options).then(symlinks => {
    symlinks.forEach(symlink => {
        console.log(symlink.path, '', symlink.target);
    });
});

Related

  • ln-cli - Create or delete symbolic link using glob on CLI.
  • del-symlinks - Delete symlinks using glob.
  • get-symlinks - Get all symbolic link (file symlinks) using glob.

License

MIT © Guntur Poetra

Package Sidebar

Install

npm i make-symlinks

Weekly Downloads

31

Version

2.0.1

License

MIT

Unpacked Size

9.4 kB

Total Files

5

Last publish

Collaborators

  • guntur